diff --git a/Jakefile.js b/Jakefile.js index d20ada3a6ad..889d7cf6299 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -17,7 +17,7 @@ var docDirectory = "doc/"; var builtDirectory = "built/"; var builtLocalDirectory = "built/local/"; -var LKGDirectory = "bin/"; +var LKGDirectory = "lib/"; var copyright = "CopyrightNotice.txt"; var thirdParty = "ThirdPartyNoticeText.txt"; @@ -151,7 +151,10 @@ var harnessSources = harnessCoreSources.concat([ "session.ts", "versionCache.ts", "convertToBase64.ts", - "transpile.ts" + "transpile.ts", + "reuseProgramStructure.ts", + "cachingInServerLSHost.ts", + "moduleResolution.ts" ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ @@ -165,10 +168,10 @@ var harnessSources = harnessCoreSources.concat([ var librarySourceMap = [ { target: "lib.core.d.ts", sources: ["core.d.ts"] }, - { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, - { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, + { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, + { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, { target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, - { target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, + { target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, { target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]}, { target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }, ]; @@ -244,7 +247,7 @@ function compileFile(outFile, sources, prereqs, opts, callback) { , diagnostics = opts && opts.diagnostics; var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; - var options = "--module commonjs -noImplicitAny"; + var options = "--module commonjs --noImplicitAny --noEmitOnError"; // Keep comments when specifically requested // or when in debug mode. diff --git a/README.md b/README.md index 77053fc9166..c474f62fb4c 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,21 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang). +[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). +## Installing + +For the latest stable version: + +``` +npm install -g typescript +``` + +For our nightly builds: + +``` +npm install -g typescript@next +``` ## Contribute diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts deleted file mode 100644 index a265b5c2a95..00000000000 --- a/bin/lib.core.d.ts +++ /dev/null @@ -1,1199 +0,0 @@ -/*! ***************************************************************************** -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: T): T; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: T): T; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: T): T; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: any): string[]; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare 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; - - /** Returns the primitive value of the specified object. */ - valueOf(): 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; - - /** Returns the primitive value of the specified object. */ - valueOf(): number; -} - -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. - * @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 regExp 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): arg is Array; - prototype: Array; -} - -declare var Array: ArrayConstructor; - -interface TypedPropertyDescriptor { - enumerable?: boolean; - configurable?: boolean; - writable?: boolean; - value?: T; - get?: () => T; - set?: (value: T) => void; -} - -declare type ClassDecorator = (target: TFunction) => TFunction | void; -declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; -declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; -declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; - -declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; - -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} diff --git a/bin/tsc b/bin/tsc index 3c0dab574f2..19c62bf7a00 100755 --- a/bin/tsc +++ b/bin/tsc @@ -1,2 +1,2 @@ #!/usr/bin/env node -require('./tsc.js') +require('../lib/tsc.js') diff --git a/bin/tsserver b/bin/tsserver old mode 100644 new mode 100755 index 003eb0d22af..7143b6a73ab --- a/bin/tsserver +++ b/bin/tsserver @@ -1,2 +1,2 @@ #!/usr/bin/env node -require('./tsserver.js') +require('../lib/tsserver.js') diff --git a/doc/TypeScript Language Specification (Change Markup).docx b/doc/TypeScript Language Specification (Change Markup).docx index fd2688234c3..893f2e7ed22 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).docx and b/doc/TypeScript Language Specification (Change Markup).docx differ diff --git a/doc/TypeScript Language Specification (Change Markup).pdf b/doc/TypeScript Language Specification (Change Markup).pdf index 7cb0009047b..1b4faab62e1 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).pdf and b/doc/TypeScript Language Specification (Change Markup).pdf differ diff --git a/doc/TypeScript Language Specification.docx b/doc/TypeScript Language Specification.docx index 62604fa5bc4..4aaa3bf92fe 100644 Binary files a/doc/TypeScript Language Specification.docx and b/doc/TypeScript Language Specification.docx differ diff --git a/doc/TypeScript Language Specification.pdf b/doc/TypeScript Language Specification.pdf index e28d6f2d7f4..277fcecf2de 100644 Binary files a/doc/TypeScript Language Specification.pdf and b/doc/TypeScript Language Specification.pdf differ diff --git a/doc/spec.md b/doc/spec.md index cff436d5fc0..fe2147be477 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -1,12 +1,12 @@ # TypeScript Language Specification -Version 1.5 +Version 1.6 -February, 2015 +August, 2015
-Microsoft is making this Specification available under the Open Web Foundation Final Specification Agreement Version 1.0 ("OWF 1.0") as of October 1, 2012. The OWF 1.0 is available at http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0. +Microsoft is making this Specification available under the Open Web Foundation Final Specification Agreement Version 1.0 ("OWF 1.0") as of October 1, 2012. The OWF 1.0 is available at [http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0](http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0). TypeScript is a trademark of Microsoft Corporation. @@ -24,10 +24,14 @@ TypeScript is a trademark of Microsoft Corporation. * [1.7 Enum Types](#1.7) * [1.8 Overloading on String Parameters](#1.8) * [1.9 Generic Types and Functions](#1.9) - * [1.10 Modules](#1.10) + * [1.10 Namespaces](#1.10) + * [1.11 Modules](#1.11) * [2 Basic Concepts](#2) * [2.1 Grammar Conventions](#2.1) - * [2.2 Namespaces and Named Types](#2.2) + * [2.2 Names](#2.2) + * [2.2.1 Reserved Words](#2.2.1) + * [2.2.2 Property Names](#2.2.2) + * [2.2.3 Computed Property Names](#2.2.3) * [2.3 Declarations](#2.3) * [2.4 Scopes](#2.4) * [3 Types](#3) @@ -36,11 +40,12 @@ TypeScript is a trademark of Microsoft Corporation. * [3.2.1 The Number Type](#3.2.1) * [3.2.2 The Boolean Type](#3.2.2) * [3.2.3 The String Type](#3.2.3) - * [3.2.4 The Void Type](#3.2.4) - * [3.2.5 The Null Type](#3.2.5) - * [3.2.6 The Undefined Type](#3.2.6) - * [3.2.7 Enum Types](#3.2.7) - * [3.2.8 String Literal Types](#3.2.8) + * [3.2.4 The Symbol Type](#3.2.4) + * [3.2.5 The Void Type](#3.2.5) + * [3.2.6 The Null Type](#3.2.6) + * [3.2.7 The Undefined Type](#3.2.7) + * [3.2.8 Enum Types](#3.2.8) + * [3.2.9 String Literal Types](#3.2.9) * [3.3 Object Types](#3.3) * [3.3.1 Named Type References](#3.3.1) * [3.3.2 Array Types](#3.3.2) @@ -49,38 +54,40 @@ TypeScript is a trademark of Microsoft Corporation. * [3.3.5 Constructor Types](#3.3.5) * [3.3.6 Members](#3.3.6) * [3.4 Union Types](#3.4) - * [3.4.1 Contextual Union Types](#3.4.1) - * [3.5 Type Parameters](#3.5) - * [3.5.1 Type Parameter Lists](#3.5.1) - * [3.5.2 Type Argument Lists](#3.5.2) - * [3.6 Named Types](#3.6) - * [3.6.1 Instance Types](#3.6.1) - * [3.7 Specifying Types](#3.7) - * [3.7.1 Predefined Types](#3.7.1) - * [3.7.2 Type References](#3.7.2) - * [3.7.3 Object Type Literals](#3.7.3) - * [3.7.4 Array Type Literals](#3.7.4) - * [3.7.5 Tuple Type Literals](#3.7.5) - * [3.7.6 Union Type Literals](#3.7.6) - * [3.7.7 Function Type Literals](#3.7.7) - * [3.7.8 Constructor Type Literals](#3.7.8) - * [3.7.9 Type Queries](#3.7.9) - * [3.8 Specifying Members](#3.8) - * [3.8.1 Property Signatures](#3.8.1) - * [3.8.2 Call Signatures](#3.8.2) - * [3.8.3 Construct Signatures](#3.8.3) - * [3.8.4 Index Signatures](#3.8.4) - * [3.8.5 Method Signatures](#3.8.5) - * [3.9 Type Aliases](#3.9) - * [3.10 Type Relationships](#3.10) - * [3.10.1 Apparent Members](#3.10.1) - * [3.10.2 Type and Member Identity](#3.10.2) - * [3.10.3 Subtypes and Supertypes](#3.10.3) - * [3.10.4 Assignment Compatibility](#3.10.4) - * [3.10.5 Contextual Signature Instantiation](#3.10.5) - * [3.10.6 Type Inference](#3.10.6) - * [3.10.7 Recursive Types](#3.10.7) - * [3.11 Widened Types](#3.11) + * [3.5 Intersection Types](#3.5) + * [3.6 Type Parameters](#3.6) + * [3.6.1 Type Parameter Lists](#3.6.1) + * [3.6.2 Type Argument Lists](#3.6.2) + * [3.7 Named Types](#3.7) + * [3.7.1 Instance Types](#3.7.1) + * [3.8 Specifying Types](#3.8) + * [3.8.1 Predefined Types](#3.8.1) + * [3.8.2 Type References](#3.8.2) + * [3.8.3 Object Type Literals](#3.8.3) + * [3.8.4 Array Type Literals](#3.8.4) + * [3.8.5 Tuple Type Literals](#3.8.5) + * [3.8.6 Union Type Literals](#3.8.6) + * [3.8.7 Intersection Type Literals](#3.8.7) + * [3.8.8 Function Type Literals](#3.8.8) + * [3.8.9 Constructor Type Literals](#3.8.9) + * [3.8.10 Type Queries](#3.8.10) + * [3.9 Specifying Members](#3.9) + * [3.9.1 Property Signatures](#3.9.1) + * [3.9.2 Call Signatures](#3.9.2) + * [3.9.3 Construct Signatures](#3.9.3) + * [3.9.4 Index Signatures](#3.9.4) + * [3.9.5 Method Signatures](#3.9.5) + * [3.10 Type Aliases](#3.10) + * [3.11 Type Relationships](#3.11) + * [3.11.1 Apparent Members](#3.11.1) + * [3.11.2 Type and Member Identity](#3.11.2) + * [3.11.3 Subtypes and Supertypes](#3.11.3) + * [3.11.4 Assignment Compatibility](#3.11.4) + * [3.11.5 Excess Properties](#3.11.5) + * [3.11.6 Contextual Signature Instantiation](#3.11.6) + * [3.11.7 Type Inference](#3.11.7) + * [3.11.8 Recursive Types](#3.11.8) + * [3.12 Widened Types](#3.12) * [4 Expressions](#4) * [4.1 Values and References](#4.1) * [4.2 The this Keyword](#4.2) @@ -88,57 +95,61 @@ TypeScript is a trademark of Microsoft Corporation. * [4.4 Literals](#4.4) * [4.5 Object Literals](#4.5) * [4.6 Array Literals](#4.6) - * [4.7 Parentheses](#4.7) - * [4.8 The super Keyword](#4.8) - * [4.8.1 Super Calls](#4.8.1) - * [4.8.2 Super Property Access](#4.8.2) - * [4.9 Function Expressions](#4.9) - * [4.9.1 Standard Function Expressions](#4.9.1) - * [4.9.2 Arrow Function Expressions](#4.9.2) - * [4.9.3 Contextually Typed Function Expressions](#4.9.3) - * [4.10 Property Access](#4.10) - * [4.11 The new Operator](#4.11) - * [4.12 Function Calls](#4.12) - * [4.12.1 Overload Resolution](#4.12.1) - * [4.12.2 Type Argument Inference](#4.12.2) - * [4.12.3 Grammar Ambiguities](#4.12.3) - * [4.13 Type Assertions](#4.13) - * [4.14 Unary Operators](#4.14) - * [4.14.1 The ++ and -- operators](#4.14.1) - * [4.14.2 The +, –, and ~ operators](#4.14.2) - * [4.14.3 The ! operator](#4.14.3) - * [4.14.4 The delete Operator](#4.14.4) - * [4.14.5 The void Operator](#4.14.5) - * [4.14.6 The typeof Operator](#4.14.6) - * [4.15 Binary Operators](#4.15) - * [4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators](#4.15.1) - * [4.15.2 The + operator](#4.15.2) - * [4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators](#4.15.3) - * [4.15.4 The instanceof operator](#4.15.4) - * [4.15.5 The in operator](#4.15.5) - * [4.15.6 The && operator](#4.15.6) - * [4.15.7 The || operator](#4.15.7) - * [4.16 The Conditional Operator](#4.16) - * [4.17 Assignment Operators](#4.17) - * [4.17.1 Destructuring Assignment](#4.17.1) - * [4.18 The Comma Operator](#4.18) - * [4.19 Contextually Typed Expressions](#4.19) - * [4.20 Type Guards](#4.20) + * [4.7 Template Literals](#4.7) + * [4.8 Parentheses](#4.8) + * [4.9 The super Keyword](#4.9) + * [4.9.1 Super Calls](#4.9.1) + * [4.9.2 Super Property Access](#4.9.2) + * [4.10 Function Expressions](#4.10) + * [4.11 Arrow Functions](#4.11) + * [4.12 Class Expressions](#4.12) + * [4.13 Property Access](#4.13) + * [4.14 The new Operator](#4.14) + * [4.15 Function Calls](#4.15) + * [4.15.1 Overload Resolution](#4.15.1) + * [4.15.2 Type Argument Inference](#4.15.2) + * [4.15.3 Grammar Ambiguities](#4.15.3) + * [4.16 Type Assertions](#4.16) + * [4.17 JSX Expressions](#4.17) + * [4.18 Unary Operators](#4.18) + * [4.18.1 The ++ and -- operators](#4.18.1) + * [4.18.2 The +, –, and ~ operators](#4.18.2) + * [4.18.3 The ! operator](#4.18.3) + * [4.18.4 The delete Operator](#4.18.4) + * [4.18.5 The void Operator](#4.18.5) + * [4.18.6 The typeof Operator](#4.18.6) + * [4.19 Binary Operators](#4.19) + * [4.19.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators](#4.19.1) + * [4.19.2 The + operator](#4.19.2) + * [4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators](#4.19.3) + * [4.19.4 The instanceof operator](#4.19.4) + * [4.19.5 The in operator](#4.19.5) + * [4.19.6 The && operator](#4.19.6) + * [4.19.7 The || operator](#4.19.7) + * [4.20 The Conditional Operator](#4.20) + * [4.21 Assignment Operators](#4.21) + * [4.21.1 Destructuring Assignment](#4.21.1) + * [4.22 The Comma Operator](#4.22) + * [4.23 Contextually Typed Expressions](#4.23) + * [4.24 Type Guards](#4.24) * [5 Statements](#5) - * [5.1 Variable Statements](#5.1) - * [5.1.1 Simple Variable Declarations](#5.1.1) - * [5.1.2 Destructuring Variable Declarations](#5.1.2) - * [5.1.3 Implied Type](#5.1.3) - * [5.2 If, Do, and While Statements](#5.2) - * [5.3 For Statements](#5.3) - * [5.4 For-In Statements](#5.4) - * [5.5 Continue Statements](#5.5) - * [5.6 Break Statements](#5.6) - * [5.7 Return Statements](#5.7) - * [5.8 With Statements](#5.8) - * [5.9 Switch Statements](#5.9) - * [5.10 Throw Statements](#5.10) - * [5.11 Try Statements](#5.11) + * [5.1 Blocks](#5.1) + * [5.2 Variable Statements](#5.2) + * [5.2.1 Simple Variable Declarations](#5.2.1) + * [5.2.2 Destructuring Variable Declarations](#5.2.2) + * [5.2.3 Implied Type](#5.2.3) + * [5.3 Let and Const Declarations](#5.3) + * [5.4 If, Do, and While Statements](#5.4) + * [5.5 For Statements](#5.5) + * [5.6 For-In Statements](#5.6) + * [5.7 For-Of Statements](#5.7) + * [5.8 Continue Statements](#5.8) + * [5.9 Break Statements](#5.9) + * [5.10 Return Statements](#5.10) + * [5.11 With Statements](#5.11) + * [5.12 Switch Statements](#5.12) + * [5.13 Throw Statements](#5.13) + * [5.14 Try Statements](#5.14) * [6 Functions](#6) * [6.1 Function Declarations](#6.1) * [6.2 Function Overloads](#6.2) @@ -146,6 +157,8 @@ TypeScript is a trademark of Microsoft Corporation. * [6.4 Destructuring Parameter Declarations](#6.4) * [6.5 Generic Functions](#6.5) * [6.6 Code Generation](#6.6) + * [6.7 Generator Functions](#6.7) + * [6.8 Type Guard Functions](#6.8) * [7 Interfaces](#7) * [7.1 Interface Declarations](#7.1) * [7.2 Declaration Merging](#7.2) @@ -169,6 +182,7 @@ TypeScript is a trademark of Microsoft Corporation. * [8.4.1 Member Variable Declarations](#8.4.1) * [8.4.2 Member Function Declarations](#8.4.2) * [8.4.3 Member Accessor Declarations](#8.4.3) + * [8.4.4 Dynamic Property Declarations](#8.4.4) * [8.5 Index Member Declarations](#8.5) * [8.6 Code Generation](#8.6) * [8.6.1 Classes Without Extends Clauses](#8.6.1) @@ -179,31 +193,33 @@ TypeScript is a trademark of Microsoft Corporation. * [9.3 Declaration Merging](#9.3) * [9.4 Constant Enum Declarations](#9.4) * [9.5 Code Generation](#9.5) -* [10 Internal Modules](#10) - * [10.1 Module Declarations](#10.1) - * [10.2 Module Body](#10.2) - * [10.3 Import Declarations](#10.3) +* [10 Namespaces](#10) + * [10.1 Namespace Declarations](#10.1) + * [10.2 Namespace Body](#10.2) + * [10.3 Import Alias Declarations](#10.3) * [10.4 Export Declarations](#10.4) * [10.5 Declaration Merging](#10.5) * [10.6 Code Generation](#10.6) -* [11 Source Files and External Modules](#11) - * [11.1 Source Files](#11.1) +* [11 Scripts and Modules](#11) + * [11.1 Programs and Source Files](#11.1) * [11.1.1 Source Files Dependencies](#11.1.1) - * [11.2 External Modules](#11.2) - * [11.2.1 External Module Names](#11.2.1) - * [11.2.2 External Import Declarations](#11.2.2) - * [11.2.3 Export Declarations](#11.2.3) - * [11.2.4 Export Assignments](#11.2.4) - * [11.2.5 CommonJS Modules](#11.2.5) - * [11.2.6 AMD Modules](#11.2.6) + * [11.2 Scripts](#11.2) + * [11.3 Modules](#11.3) + * [11.3.1 Module Names](#11.3.1) + * [11.3.2 Import Declarations](#11.3.2) + * [11.3.3 Import Require Declarations](#11.3.3) + * [11.3.4 Export Declarations](#11.3.4) + * [11.3.5 Export Assignments](#11.3.5) + * [11.3.6 CommonJS Modules](#11.3.6) + * [11.3.7 AMD Modules](#11.3.7) * [12 Ambients](#12) * [12.1 Ambient Declarations](#12.1) * [12.1.1 Ambient Variable Declarations](#12.1.1) * [12.1.2 Ambient Function Declarations](#12.1.2) * [12.1.3 Ambient Class Declarations](#12.1.3) * [12.1.4 Ambient Enum Declarations](#12.1.4) - * [12.1.5 Ambient Module Declarations](#12.1.5) - * [12.2 Ambient External Module Declarations](#12.2) + * [12.1.5 Ambient Namespace Declarations](#12.1.5) + * [12.2 Ambient Module Declarations](#12.2) * [A Grammar](#A) * [A.1 Types](#A.1) * [A.2 Expressions](#A.2) @@ -212,8 +228,8 @@ TypeScript is a trademark of Microsoft Corporation. * [A.5 Interfaces](#A.5) * [A.6 Classes](#A.6) * [A.7 Enums](#A.7) - * [A.8 Internal Modules](#A.8) - * [A.9 Source Files and External Modules](#A.9) + * [A.8 Namespaces](#A.8) + * [A.9 Scripts and Modules](#A.9) * [A.10 Ambients](#A.10)
@@ -222,9 +238,11 @@ TypeScript is a trademark of Microsoft Corporation. JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring. -TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of Ecmascript 5 (ES5) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development. +TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of ECMAScript 6 (ES6) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development. -TypeScript syntax includes several proposed features of Ecmascript 6 (ES6), including classes and modules. Classes enable programmers to express common object-oriented patterns in a standard way, making features like inheritance more readable and interoperable. Modules enable programmers to organize their code into components while avoiding naming conflicts. The TypeScript compiler provides module code generation options that support either static or dynamic loading of module contents. +TypeScript syntax includes all features of ECMAScript 6 (ES6), including classes and modules, and provides the ability to translate these features into ECMAScript 3 or 5 compliant code. + +Classes enable programmers to express common object-oriented patterns in a standard way, making features like inheritance more readable and interoperable. Modules enable programmers to organize their code into components while avoiding naming conflicts. The TypeScript compiler provides module code generation options that support either static or dynamic loading of module contents. TypeScript also provides to JavaScript programmers a system of optional type annotations. These type annotations are like the JSDoc comments found in the Closure system, but in TypeScript they are integrated directly into the language syntax. This integration makes the code more readable and reduces the maintenance cost of synchronizing type annotations with their corresponding variables. @@ -314,7 +332,7 @@ In this example, the second parameter to 'vote' has the function type which means the second parameter is a function returning type 'any' that has a single parameter of type 'string' named 'result'. -Section [3.8.2](#3.8.2) provides additional information about function types. +Section [3.9.2](#3.9.2) provides additional information about function types. ## 1.3 Object Types @@ -426,7 +444,7 @@ getX({ x: 0, y: 0, color: "red" }); // Extra fields Ok getX({ x: 0 }); // Error: supplied parameter does not match ``` -See section [3.10](#3.10) for more information about type comparisons. +See section [3.11](#3.11) for more information about type comparisons. ## 1.5 Contextual Typing @@ -452,13 +470,13 @@ $.get("http://mysite.org/divContent", Contextual typing is also useful for writing out object literals. As the programmer types the object literal, the contextual type provides information that enables tools to provide completion for object member names. -Section [4.19](#4.19) provides additional information about contextually typed expressions. +Section [4.23](#4.23) provides additional information about contextually typed expressions. ## 1.6 Classes -JavaScript practice has at least two common design patterns: the module pattern and the class pattern. Roughly speaking, the module pattern uses closures to hide names and to encapsulate private data, while the class pattern uses prototype chains to implement many variations on object-oriented inheritance mechanisms. Libraries such as 'prototype.js' are typical of this practice. +JavaScript practice has two very common design patterns: the module pattern and the class pattern. Roughly speaking, the module pattern uses closures to hide names and to encapsulate private data, while the class pattern uses prototype chains to implement many variations on object-oriented inheritance mechanisms. Libraries such as 'prototype.js' are typical of this practice. TypeScript's namespaces are a formalization of the module pattern. (The term "module pattern" is somewhat unfortunate now that ECMAScript 6 formally supports modules in a manner different from what the module pattern prescribes. For this reason, TypeScript uses the term "namespace" for its formalization of the module pattern.) -This section and the module section below will show how TypeScript emits consistent, idiomatic JavaScript code to implement classes and modules that are closely aligned with the current ES6 proposal. The goal of TypeScript's translation is to emit exactly what a programmer would type when implementing a class or module unaided by a tool. This section will also describe how TypeScript infers a type for each class declaration. We'll start with a simple BankAccount class. +This section and the namespace section below will show how TypeScript emits consistent, idiomatic JavaScript when emitting ECMAScript 3 or 5 compliant code for classes and namespaces. The goal of TypeScript's translation is to emit exactly what a programmer would type when implementing a class or namespace unaided by a tool. This section will also describe how TypeScript infers a type for each class declaration. We'll start with a simple BankAccount class. ```TypeScript class BankAccount { @@ -556,7 +574,7 @@ Section [8](#8) provides additional information about classes. TypeScript enables programmers to summarize a set of numeric constants as an *enum type*. The example below creates an enum type to represent operators in a calculator application. ```TypeScript -enum Operator { +const enum Operator { ADD, DIV, MUL, @@ -571,7 +589,7 @@ function compute(op: Operator, a: number, b: number) { In this example, the compute function logs the operator 'op' using a feature of enum types: reverse mapping from the enum value ('op') to the string corresponding to that value. For example, the declaration of 'Operator' automatically assigns integers, starting from zero, to the listed enum members. Section [9](#9) describes how programmers can also explicitly assign integers to enum members, and can use any string to name an enum member. -If all enum members have explicitly assigned literal integers, or if an enum has all members automatically assigned, the TypeScript compiler will emit for an enum member a JavaScript constant corresponding to that member's assigned value (annotated with a comment). This improves performance on many JavaScript engines. +When enums are declared with the `const` modifier, the TypeScript compiler will emit for an enum member a JavaScript constant corresponding to that member's assigned value (annotated with a comment). This improves performance on many JavaScript engines. For example, the 'compute' function could contain a switch statement like the following. @@ -622,7 +640,7 @@ In the following screen shot, a programming tool combines information from overl / -Section [3.8.2.4](#3.8.2.4) provides details on how to use string literals in function signatures. +Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures. ## 1.9 Generic Types and Functions @@ -686,13 +704,13 @@ class List { } ``` -Section [3.6](#3.6) provides further information about generic types. +Section [3.7](#3.7) provides further information about generic types. -## 1.10 Modules +## 1.10 Namespaces Classes and interfaces support large-scale JavaScript development by providing a mechanism for describing how to use a software component that can be separated from that component's implementation. TypeScript enforces *encapsulation* of implementation in classes at design time (by restricting use of private and protected members), but cannot enforce encapsulation at runtime because all object properties are accessible at runtime. Future versions of JavaScript may provide *private names* which would enable runtime enforcement of private and protected members. -In the current version of JavaScript, the only way to enforce encapsulation at runtime is to use the module pattern: encapsulate private fields and methods using closure variables. The module pattern is a natural way to provide organizational structure and dynamic loading options by drawing a boundary around a software component. A module can also provide the ability to introduce namespaces, avoiding use of the global namespace for most software components. +In JavaScript, a very common way to enforce encapsulation at runtime is to use the module pattern: encapsulate private fields and methods using closure variables. The module pattern is a natural way to provide organizational structure and dynamic loading options by drawing a boundary around a software component. The module pattern can also provide the ability to introduce namespaces, avoiding use of the global namespace for most software components. The following example illustrates the JavaScript module pattern. @@ -710,12 +728,12 @@ This example illustrates the two essential elements of the module pattern: a *mo The example assumes that an outer lexical scope defines the functions 'generateSecretKey' and 'sendSecureMessage'; it also assumes that the outer scope has assigned the module object to the variable 'MessageModule'. -TypeScript modules provide a mechanism for succinctly expressing the module pattern. In TypeScript, programmers can combine the module pattern with the class pattern by nesting modules and classes within an outer module. +TypeScript namespaces provide a mechanism for succinctly expressing the module pattern. In TypeScript, programmers can combine the module pattern with the class pattern by nesting namespaces and classes within an outer namespace. -The following example shows the definition and use of a simple module. +The following example shows the definition and use of a simple namespace. ```TypeScript -module M { +namespace M { var s = "hello"; export function f() { return s; @@ -726,7 +744,7 @@ M.f(); M.s; // Error, s is not exported ``` -In this example, variable 's' is a private feature of the module, but function 'f' is exported from the module and accessible to code outside of the module. If we were to describe the effect of module 'M' in terms of interfaces and variables, we would write +In this example, variable 's' is a private feature of the namespace, but function 'f' is exported from the namespace and accessible to code outside of the namespace. If we were to describe the effect of namespace 'M' in terms of interfaces and variables, we would write ```TypeScript interface M { @@ -736,9 +754,9 @@ interface M { var M: M; ``` -The interface 'M' summarizes the externally visible behavior of module 'M'. In this example, we can use the same name for the interface as for the initialized variable because in TypeScript type names and variable names do not conflict: each lexical scope contains a variable declaration space and type declaration space (see section [2.3](#2.3) for more details). +The interface 'M' summarizes the externally visible behavior of namespace 'M'. In this example, we can use the same name for the interface as for the initialized variable because in TypeScript type names and variable names do not conflict: each lexical scope contains a variable declaration space and type declaration space (see section [2.3](#2.3) for more details). -Module 'M' is an example of an *internal* module, because it is nested within the *global* module (see section [10](#10) for more details). The TypeScript compiler emits the following JavaScript code for this module. +The TypeScript compiler emits the following JavaScript code for the namespace: ```TypeScript var M; @@ -751,110 +769,200 @@ var M; })(M || (M = {})); ``` -In this case, the compiler assumes that the module object resides in global variable 'M', which may or may not have been initialized to the desired module object. +In this case, the compiler assumes that the namespace object resides in global variable 'M', which may or may not have been initialized to the desired namespace object. -TypeScript also supports *external* modules, which are files that contain top-level *export* and *import *directives. For this type of module the TypeScript compiler will emit code whose module closure and module object implementation vary according to the specified dynamic loading system, for example, the Asynchronous Module Definition system. +## 1.11 Modules + +TypeScript also supports ECMAScript 6 modules, which are files that contain top-level *export* and *import* directives. For this type of module the TypeScript compiler can emit both ECMAScript 6 compliant code and down-level ECMAScript 3 or 5 compliant code for a variety of module loading systems, including CommonJS, Asynchronous Module Definition (AMD), and Universal Module Definition (UMD).
#
2 Basic Concepts -The remainder of this document is the formal specification of the TypeScript programming language and is intended to be read as an adjunct to the ECMAScript Language Specification (specifically, the ECMA-262 Standard, 5th Edition). This document describes the syntactic grammar added by TypeScript along with the compile-time processing and type checking performed by the TypeScript compiler, but it only minimally discusses the run-time behavior of programs since that is covered by the ECMAScript specification. +The remainder of this document is the formal specification of the TypeScript programming language and is intended to be read as an adjunct to the [ECMAScript Language Specification](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) (specifically, the ECMA-262 Standard, 6th Edition). This document describes the syntactic grammar added by TypeScript along with the compile-time processing and type checking performed by the TypeScript compiler, but it only minimally discusses the run-time behavior of programs since that is covered by the ECMAScript specification. ## 2.1 Grammar Conventions The syntactic grammar added by TypeScript language is specified throughout this document using the existing conventions and production names of the ECMAScript grammar. In places where TypeScript augments an existing grammar production it is so noted. For example: -  *CallExpression:* *( Modified )* +  *Declaration:* *( Modified )*    … -   `super` `(` *ArgumentListopt* `)` -   `super` `.` *IdentifierName* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* The '*( Modified )*' annotation indicates that an existing grammar production is being replaced, and the '…' references the contents of the original grammar production. Similar to the ECMAScript grammar, if the phrase "*[no LineTerminator here]*" appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is not a match if a *LineTerminator* occurs in the input stream at the indicated position. -## 2.2 Namespaces and Named Types +## 2.2 Names -TypeScript supports ***named types*** that can be organized in hierarchical ***namespaces***. Namespaces are introduced by module declarations and named types are introduced by class, interface, and enum declarations. Named types are denoted by qualified names that extend from some root module (possibly the global module) to the point of their declaration. The example +A core purpose of the TypeScript compiler is to track the named entities in a program and validate that they are used according to their designated meaning. Names in TypeScript can be written in several ways, depending on context. Specifically, a name can be written as + +* an *IdentifierName*, +* a *StringLiteral* in a property name, +* a *NumericLiteral* in a property name, or +* a *ComputedPropertyName* that denotes a well-known symbol ([2.2.3](#2.2.3)). + +Most commonly, names are written to conform with the *Identifier* production, which is any *IdentifierName* that isn't a reserved word. + +### 2.2.1 Reserved Words + +The following keywords are reserved and cannot be used as an *Identifier*: ```TypeScript -module X { - export module Y { - export interface Z { } - } - export interface Y { } +break case catch class +const continue debugger default +delete do else enum +export extends false finally +for function if import +in instanceof new null +return super switch this +throw true try typeof +var void while with +``` + +The following keywords cannot be used as identifiers in strict mode code, but are otherwise not restricted: + +```TypeScript +implements interface let package +private protected public static +yield +``` + +The following keywords cannot be used as user defined type names, but are otherwise not restricted: + +```TypeScript +any boolean number string +symbol +``` + +The following keywords have special meaning in certain contexts, but are valid identifiers: + +```TypeScript +abstract as async await +constructor declare from get +is module namespace of +require set type +``` + +### 2.2.2 Property Names + +The *PropertyName* production from the ECMAScript grammar is reproduced below: + +  *PropertyName:* +   *LiteralPropertyName* +   *ComputedPropertyName* + +  *LiteralPropertyName:* +   *IdentifierName* +   *StringLiteral* +   *NumericLiteral* + +  *ComputedPropertyName:* +   `[` *AssignmentExpression* `]` + +A property name can be any identifier (including a reserved word), a string literal, a numeric literal, or a computed property name. String literals may be used to give properties names that are not valid identifiers, such as names containing blanks. Numeric literal property names are equivalent to string literal property names with the string representation of the numeric literal, as defined in the ECMAScript specification. + +### 2.2.3 Computed Property Names + +ECMAScript 6 permits object literals and classes to declare members with computed property names. A computed property name specifies an expression that computes the actual property name at run-time. Because the final property name isn't known at compile-time, TypeScript can only perform limited checks for entities declared with computed property names. However, a subset of computed property names known as ***well-known symbols*** can be used anywhere a *PropertyName* is expected, including property names within types. A computed property name is a well-known symbol if it is of the form + +```TypeScript +[ Symbol . xxx ] +``` + +In a well-known symbol, the identifier to the right of the dot must denote a property of the primitive type `symbol` in the type of the global variable 'Symbol', or otherwise an error occurs. + +In a *PropertyName* that specifies a *ComputedPropertyName*, the computed property name is required to denote a well-known symbol unless the property name occurs in a property assignment of an object literal ([4.5](#4.5)) or a property member declaration in a non-ambient class ([8.4](#8.4)). + +Below is an example of an interface that declares a property with a well-known symbol name: + +```TypeScript +interface Iterable { + [Symbol.iterator](): Iterator; } ``` -declares two interface types with the qualified names 'X.Y.Z' and 'X.Y' relative to the root module in which 'X' is declared. - -In a qualified type name all identifiers but the last one refer to namespaces and the last identifier refers to a named type. Named type and namespace names are in separate declaration spaces and it is therefore possible for a named type and a namespace to have the same name, as in the example above. - -The hierarchy formed by namespace and named type names partially mirrors that formed by module instances and members. The example - -```TypeScript -module A { - export module B { - export class C { } - } -} -``` - -introduces a named type with the qualified name 'A.B.C' and also introduces a constructor function that can be accessed using the expression 'A.B.C'. Thus, in the example - -```TypeScript -var c: A.B.C = new A.B.C(); -``` - -the two occurrences of 'A.B.C' in fact refer to different entities. It is the context of the occurrences that determines whether 'A.B.C' is processed as a type name or an expression. - ## 2.3 Declarations -Declarations introduce names in the ***declaration spaces*** to which they belong. It is an error to have two names with same spelling in the same declaration space. Declaration spaces exist as follows: - -* The global module and each external or internal module has a declaration space for variables (including functions, modules, class constructor functions, and enum objects), a declaration space for named types (classes, interfaces, and enums), and a declaration space for namespaces (containers of named types). Every declaration (whether local or exported) in a module contributes to one or more of these declaration spaces. -* Each external or internal module has a declaration space for exported members, a declaration space for exported named types, and a declaration space for exported namespaces. All export declarations in the module contribute to these declaration spaces. Each internal module's export declaration spaces are shared with other internal modules that have the same root module and the same qualified name starting from that root module. -* Each class declaration has a declaration space for instance members, a declaration space for static members, and a declaration space for type parameters. -* Each interface declaration has a declaration space for members and a declaration space for type parameters. An interface's declaration space is shared with other interfaces that have the same root module and the same qualified name starting from that root module. -* Each enum declaration has a declaration space for its enum members. An enum's declaration space is shared with other enums that have the same root module and the same qualified name starting from that root module. -* Each function declaration (including constructor, member function, and member accessor declarations) and each function expression has a declaration space for locals (introduced by parameter, variable, and function declarations) and a declaration space for type parameters. -* Each object literal has a declaration space for its properties. -* Each object type literal has a declaration space for its members. - -Top-level declarations in a source file with no top-level import or export declarations belong to the ***global module***. Top-level declarations in a source file with one or more top-level import or export declarations belong to the ***external module*** represented by that source file. - -An internal module declaration contributes a namespace name (representing a container of types) and possibly a member name (representing the module instance) to the containing module. A class declaration contributes both a member name (representing the constructor function) and a type name (representing the class type) to the containing module. An interface declaration contributes a type name to the containing module. An enum declaration contributes both a member name (representing the enum object) and a type name (representing the enum type) to the containing module. Any other declaration contributes a member name to the declaration space to which it belongs. - -The ***parent module*** of an entity is defined as follows: - -* The parent module of an entity declared in an internal module is that internal module. -* The parent module of an entity declared in an external module is that external module. -* The parent module of an entity declared in the global module is the global module. -* The parent module of an external module is the global module. - -The ***root module*** of an entity is defined as follows: - -* The root module of a non-exported entity is the entity's parent module. -* The root module of an exported entity is the root module of the entity's parent module. - -Intuitively, the root module of an entity is the outermost module body from within which the entity is reachable. - -Interfaces, enums, and internal modules are "open ended," meaning that interface, enum, and internal module declarations with the same qualified name relative to a common root are automatically merged. For further details, see sections [7.2](#7.2), [9.3](#9.3), and [10.5](#10.5). - -Namespace, type, and member names exist in separate declaration spaces. Furthermore, declarations of non-instantiated modules (modules that contain only interfaces or modules at all levels of nesting) do not introduce a member name in their containing declaration space. This means that the following is permitted, provided module 'X' contains only interface or module declarations at all levels of nesting: +Declarations introduce names in their associated ***declaration spaces***. A name must be unique in its declaration space and can denote a ***value***, a ***type***, or a ***namespace***, or some combination thereof. Effectively, a single name can have as many as three distinct meanings. For example: ```TypeScript -module M { - module X { ... } // Namespace - interface X { ... } // Type - var X; // Member +var X: string; // Value named X + +type X = number; // Type named X + +namespace X { // Namespace named X + type Y = string; } ``` -If module 'X' above was an instantiated module (section [10.1](#10.1)) it would cause a member 'X' to be introduced in 'M'. This member would conflict with the variable 'X' and thus cause an error. +A name that denotes a value has an associated type (section [3](#3)) and can be referenced in expressions (section [4.3](#4.3)). A name that denotes a type can be used by itself in a type reference or on the right hand side of a dot in a type reference ([3.8.2](#3.8.2)). A name that denotes a namespace can be used one the left hand side of a dot in a type reference. -Instance and static members in a class are likewise in separate declaration spaces. Thus the following is permitted: +When a name with multiple meanings is referenced, the context in which the reference occurs determines the meaning. For example: + +```TypeScript +var n: X; // X references type +var s: X.Y = X; // First X references namespace, second X references value +``` + +In the first line, X references the type X because it occurs in a type position. In the second line, the first X references the namespace X because it occurs before a dot in a type name, and the second X references the variable X because it occurs in an expression. + +Declarations introduce the following meanings for the name they declare: + +* A variable, parameter, function, generator, member variable, member function, member accessor, or enum member declaration introduces a value meaning. +* An interface, type alias, or type parameter declaration introduces a type meaning. +* A class declaration introduces a value meaning (the constructor function) and a type meaning (the class instance type). +* An enum declaration introduces a value meaning (the enum instance) and a type meaning (the enum type). +* A namespace declaration introduces a namespace meaning (the type and namespace container) and, if the namespace is instantiated (section [10.1](#10.1)), a value meaning (the namespace instance). +* An import or export declaration introduces the meaning(s) of the imported or exported entity. + +Below are some examples of declarations that introduce multiple meanings for a name: + +```TypeScript +class C { // Value and type named C + x: string; +} + +namespace N { // Value and namespace named N + export var x: string; +} +``` + +Declaration spaces exist as follows: + +* The global namespace, each module, and each declared namespace has a declaration space for its contained entities (whether local or exported). +* Each module has a declaration space for its exported entities. All export declarations in the module contribute to this declaration space. +* Each declared namespace has a declaration space for its exported entities. All export declarations in the namespace contribute to this declaration space. A declared namespace’s declaration space is shared with other declared namespaces that have the same root container and the same qualified name starting from that root container. +* Each class declaration has a declaration space for instance members and type parameters, and a declaration space for static members. +* Each interface declaration has a declaration space for members and type parameters. An interface's declaration space is shared with other interfaces that have the same root container and the same qualified name starting from that root container. +* Each enum declaration has a declaration space for its enum members. An enum's declaration space is shared with other enums that have the same root container and the same qualified name starting from that root container. +* Each type alias declaration has a declaration space for its type parameters. +* Each function-like declaration (including function declarations, constructor declarations, member function declarations, member accessor declarations, function expressions, and arrow functions) has a declaration space for locals and type parameters. This declaration space includes parameter declarations, all local var and function declarations, and local let, const, class, interface, type alias, and enum declarations that occur immediately within the function body and are not further nested in blocks. +* Each statement block has a declaration space for local let, const, class, interface, type alias, and enum declarations that occur immediately within that block. +* Each object literal has a declaration space for its properties. +* Each object type literal has a declaration space for its members. + +Top-level declarations in a source file with no top-level import or export declarations belong to the ***global namespace***. Top-level declarations in a source file with one or more top-level import or export declarations belong to the ***module*** represented by that source file. + +The ***container*** of an entity is defined as follows: + +* The container of an entity declared in a namespace declaration is that namespace declaration. +* The container of an entity declared in a module is that module. +* The container of an entity declared in the global namespace is the global namespace. +* The container of a module is the global namespace. + +The ***root container*** of an entity is defined as follows: + +* The root container of a non-exported entity is the entity’s container. +* The root container of an exported entity is the root container of the entity's container. + +Intuitively, the root container of an entity is the outermost module or namespace body from within which the entity is reachable. + +Interfaces, enums, and namespaces are "open ended," meaning that interface, enum, and namespace declarations with the same qualified name relative to a common root are automatically merged. For further details, see sections [7.2](#7.2), [9.3](#9.3), and [10.5](#10.5). + +Instance and static members in a class are in separate declaration spaces. Thus the following is permitted: ```TypeScript class C { @@ -867,37 +975,41 @@ class C { The ***scope*** of a name is the region of program text within which it is possible to refer to the entity declared by that name without qualification of the name. The scope of a name depends on the context in which the name is declared. The contexts are listed below in order from outermost to innermost: -* The scope of an entity declared in the global module is the entire program text. -* The scope of an entity declared in an external module is the source file of that external module. -* The scope of an exported entity declared in an internal module is the body of that module and every internal module with the same root and the same qualified name relative to that root. -* The scope of a non-exported entity declared within an internal module declaration is the body of that internal module declaration. -* The scope of a type parameter declared in a class or interface declaration is that entire declaration, including constraints, extends clause, implements clause, and declaration body, but not including static member declarations. -* The scope of a member declared in an enum declaration is the body of that declaration and every enum declaration with the same root and the same qualified name relative to that root. -* The scope of a type parameter declared in a call or construct signature is that entire signature declaration, including constraints, parameter list, and return type. If the signature is part of a function implementation, the scope includes the function body. -* The scope of a local entity (parameter, variable, or function) declared within a function declaration (including a constructor, member function, or member accessor declaration) or function expression is the body of that function declaration or function expression. +* The scope of a name declared in the global namespace is the entire program text. +* The scope of a name declared in a module is the source file of that module. +* The scope of an exported name declared within a namespace declaration is the body of that namespace declaration and every namespace declaration with the same root and the same qualified name relative to that root. +* The scope of a non-exported name declared within a namespace declaration is the body of that namespace declaration. +* The scope of a type parameter name declared in a class or interface declaration is that entire declaration, including constraints, extends clause, implements clause, and declaration body, but not including static member declarations. +* The scope of a type parameter name declared in a type alias declaration is that entire type alias declaration. +* The scope of a member name declared in an enum declaration is the body of that declaration and every enum declaration with the same root and the same qualified name relative to that root. +* The scope of a type parameter name declared in a call or construct signature is that entire signature declaration, including constraints, parameter list, and return type. If the signature is part of a function implementation, the scope includes the function body. +* The scope of a parameter name declared in a call or construct signature is the remainder of the signature declaration. If the signature is part of a function-like declaration with a body (including a function declaration, constructor declaration, member function declaration, member accessor declaration, function expression, or arrow function), the scope includes the body of that function-like declaration. +* The scope of a local var or function name declared anywhere in the body of a function-like declaration is the body of that function-like declaration. +* The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within the body of a function-like declaration is the body of that function-like declaration. +* The scope of a local let, const, class, interface, type alias, or enum declaration declared immediately within a statement block is the body of that statement block. -Scopes may overlap, for example through nesting of modules and functions. When the scopes of two entities with the same name overlap, the entity with the innermost declaration takes precedence and access to the outer entity is either not possible or only possible by qualifying its name. +Scopes may overlap, for example through nesting of namespaces and functions. When the scopes of two names overlap, the name with the innermost declaration takes precedence and access to the outer name is either not possible or only possible by qualification. -When an identifier is resolved as a *TypeName* (section [3.7.2](#3.7.2)), only classes, interfaces, enums, and type parameters are considered and other entities in scope are ignored. +When an identifier is resolved as a *PrimaryExpression* (section [4.3](#4.3)), only names in scope with a value meaning are considered and other names are ignored. -When an identifier is resolved as a *ModuleName* (section [3.7.2](#3.7.2)), only modules are considered and other entities in scope are ignored. +When an identifier is resolved as a *TypeName* (section [3.8.2](#3.8.2)), only names in scope with a type meaning are considered and other names are ignored. -When an identifier is resolved as a *PrimaryExpression* (section [4.3](#4.3)), only instantiated modules (section [10.1](#10.1)), classes, enums, functions, variables, and parameters are considered and other entities in scope are ignored. +When an identifier is resolved as a *NamespaceName* (section [3.8.2](#3.8.2)), only names in scope with a namespace meaning are considered and other names are ignored. -Note that class and enum members are never directly in scope—they can only be accessed by applying the dot ('.') operator to a class instance or enum object. This even includes members of the current instance in a constructor or member function, which are accessed by applying the dot operator to `this`. +Note that class members are never directly in scope—they can only be accessed by applying the dot ('.') operator to a class instance. This even includes members of the current instance in a constructor or member function, which are accessed by applying the dot operator to `this`. -As the rules above imply, locally declared entities in an internal module are closer in scope than exported entities declared in other module declarations for the same internal module. For example: +As the rules above imply, locally declared entities in a namespace are closer in scope than exported entities declared in other namespace declarations for the same namespace. For example: ```TypeScript var x = 1; -module M { +namespace M { export var x = 2; console.log(x); // 2 } -module M { +namespace M { console.log(x); // 2 } -module M { +namespace M { var x = 3; console.log(x); // 3 } @@ -909,15 +1021,15 @@ module M { TypeScript adds optional static types to JavaScript. Types are used to place static constraints on program entities such as functions, variables, and properties so that compilers and development tools can offer better verification and assistance during software development. TypeScript's *static* compile-time type system closely models the *dynamic* run-time type system of JavaScript, allowing programmers to accurately express the type relationships that are expected to exist when their programs run and have those assumptions pre-validated by the TypeScript compiler. TypeScript's type analysis occurs entirely at compile-time and adds no run-time overhead to program execution. -All types in TypeScript are subtypes of a single top type called the Any type. The `any` keyword references this type. The Any type is the one type that can represent *any* JavaScript value with no constraints. All other types are categorized as ***primitive types***, ***object types***, ***union types***, or ***type parameters***. These types introduce various static constraints on their values. +All types in TypeScript are subtypes of a single top type called the Any type. The `any` keyword references this type. The Any type is the one type that can represent *any* JavaScript value with no constraints. All other types are categorized as ***primitive types***, ***object types***, ***union types***, ***intersection types***, or ***type parameters***. These types introduce various static constraints on their values. -The primitive types are the Number, Boolean, String, Void, Null, and Undefined types along with user defined enum types. The `number`, `boolean`, `string`, and `void` keywords reference the Number, Boolean, String, and Void primitive types respectively. The Void type exists purely to indicate the absence of a value, such as in a function with no return value. It is not possible to explicitly reference the Null and Undefined types—only *values* of those types can be referenced, using the `null` and `undefined` literals. +The primitive types are the Number, Boolean, String, Symbol, Void, Null, and Undefined types along with user defined enum types. The `number`, `boolean`, `string`, `symbol`, and `void` keywords reference the Number, Boolean, String, Symbol, and Void primitive types respectively. The Void type exists purely to indicate the absence of a value, such as in a function with no return value. It is not possible to explicitly reference the Null and Undefined types—only *values* of those types can be referenced, using the `null` and `undefined` literals. The object types are all class, interface, array, tuple, function, and constructor types. Class and interface types are introduced through class and interface declarations and are referenced by the name given to them in their declarations. Class and interface types may be ***generic types*** which have one or more type parameters. -Union types represent values that can have one of multiple types. +Union types represent values that have one of multiple types, and intersection types represent values that simultaneously have more than one type. -Declarations of modules, classes, properties, functions, variables and other language entities associate types with those entities. The mechanism by which a type is formed and associated with a language entity depends on the particular kind of entity. For example, a module declaration associates the module with an anonymous type containing a set of properties corresponding to the exported variables and functions in the module, and a function declaration associates the function with an anonymous type containing a call signature corresponding to the parameters and return type of the function. Types can be associated with variables through explicit ***type annotations***, such as +Declarations of classes, properties, functions, variables and other language entities associate types with those entities. The mechanism by which a type is formed and associated with a language entity depends on the particular kind of entity. For example, a namespace declaration associates the namespace with an anonymous type containing a set of properties corresponding to the exported variables and functions in the namespace, and a function declaration associates the function with an anonymous type containing a call signature corresponding to the parameters and return type of the function. Types can be associated with variables through explicit ***type annotations***, such as ```TypeScript var x: number; @@ -953,7 +1065,7 @@ function f(x) { // Same as f(x: any): void ## 3.2 Primitive Types -The primitive types are the Number, Boolean, String, Void, Null, and Undefined types and all user defined enum types. +The primitive types are the Number, Boolean, String, Symbol, Void, Null, and Undefined types and all user defined enum types. ### 3.2.1 The Number Type @@ -961,7 +1073,7 @@ The Number primitive type corresponds to the similarly named JavaScript primitiv The `number` keyword references the Number primitive type and numeric literals may be used to write values of the Number primitive type. -For purposes of determining type relationships (section [3.10](#3.10)) and accessing properties (section [4.10](#4.10)), the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. +For purposes of determining type relationships (section [3.11](#3.11)) and accessing properties (section [4.13](#4.13)), the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. Some examples: @@ -978,7 +1090,7 @@ The Boolean primitive type corresponds to the similarly named JavaScript primiti The `boolean` keyword references the Boolean primitive type and the `true` and `false` literals reference the two Boolean truth values. -For purposes of determining type relationships (section [3.10](#3.10)) and accessing properties (section [4.10](#4.10)), the Boolean primitive type behaves as an object type with the same properties as the global interface type 'Boolean'. +For purposes of determining type relationships (section [3.11](#3.11)) and accessing properties (section [4.13](#4.13)), the Boolean primitive type behaves as an object type with the same properties as the global interface type 'Boolean'. Some examples: @@ -994,7 +1106,7 @@ The String primitive type corresponds to the similarly named JavaScript primitiv The `string` keyword references the String primitive type and string literals may be used to write values of the String primitive type. -For purposes of determining type relationships (section [3.10](#3.10)) and accessing properties (section [4.10](#4.10)), the String primitive type behaves as an object type with the same properties as the global interface type 'String'. +For purposes of determining type relationships (section [3.11](#3.11)) and accessing properties (section [4.13](#4.13)), the String primitive type behaves as an object type with the same properties as the global interface type 'String'. Some examples: @@ -1005,7 +1117,24 @@ var abc = 'abc'; // Same as abc: string = "abc" var c = abc.charAt(2); // Property of String interface ``` -### 3.2.4 The Void Type +### 3.2.4 The Symbol Type + +The Symbol primitive type corresponds to the similarly named JavaScript primitive type and represents unique tokens that may be used as keys for object properties. + +The `symbol` keyword references the Symbol primitive type. Symbol values are obtained using the global object 'Symbol' which has a number of methods and properties and can be invoked as a function. In particular, the global object 'Symbol' defines a number of well-known symbols ([2.2.3](#2.2.3)) that can be used in a manner similar to identifiers. Note that the 'Symbol' object is available only in ECMAScript 6 environments. + +For purposes of determining type relationships (section [3.11](#3.11)) and accessing properties (section [4.13](#4.13)), the Symbol primitive type behaves as an object type with the same properties as the global interface type 'Symbol'. + +Some examples: + +```TypeScript +var secretKey = Symbol(); +var obj = {}; +obj[secretKey] = "secret message"; // Use symbol as property key +obj[Symbol.toStringTag] = "test"; // Use of well-known symbol +``` + +### 3.2.5 The Void Type The Void type, referenced by the `void` keyword, represents the absence of a value and is used as the return type of functions with no return value. @@ -1013,13 +1142,13 @@ The only possible values for the Void type are `null` and `undefined`. The Void *NOTE: We might consider disallowing declaring variables of type Void as they serve no useful purpose. However, because Void is permitted as a type argument to a generic type or function it is not feasible to disallow Void properties or parameters*. -### 3.2.5 The Null Type +### 3.2.6 The Null Type The Null type corresponds to the similarly named JavaScript primitive type and is the type of the `null` literal. The `null` literal references the one and only value of the Null type. It is not possible to directly reference the Null type itself. -The Null type is a subtype of all types, except the Undefined type. This means that `null` is considered a valid value for all primitive types, object types, union types, and type parameters, including even the Number and Boolean primitive types. +The Null type is a subtype of all types, except the Undefined type. This means that `null` is considered a valid value for all primitive types, object types, union types, intersection types, and type parameters, including even the Number and Boolean primitive types. Some examples: @@ -1029,13 +1158,13 @@ var x = null; // Same as x: any = null var e: Null; // Error, can't reference Null type ``` -### 3.2.6 The Undefined Type +### 3.2.7 The Undefined Type The Undefined type corresponds to the similarly named JavaScript primitive type and is the type of the `undefined` literal. The `undefined` literal denotes the value given to all uninitialized variables and is the one and only value of the Undefined type. It is not possible to directly reference the Undefined type itself. -The undefined type is a subtype of all types. This means that `undefined` is considered a valid value for all primitive types, object types, union types, and type parameters. +The undefined type is a subtype of all types. This means that `undefined` is considered a valid value for all primitive types, object types, union types, intersection types, and type parameters. Some examples: @@ -1045,15 +1174,15 @@ var x = undefined; // Same as x: any = undefined var e: Undefined; // Error, can't reference Undefined type ``` -### 3.2.7 Enum Types +### 3.2.8 Enum Types -Enum types are distinct user defined subtypes of the Number primitive type. Enum types are declared using enum declarations (section [9.1](#9.1)) and referenced using type references (section [3.7.2](#3.7.2)). +Enum types are distinct user defined subtypes of the Number primitive type. Enum types are declared using enum declarations (section [9.1](#9.1)) and referenced using type references (section [3.8.2](#3.8.2)). Enum types are assignable to the Number primitive type, and vice versa, but different enum types are not assignable to each other. -### 3.2.8 String Literal Types +### 3.2.9 String Literal Types -Specialized signatures (section [3.8.2.4](#3.8.2.4)) permit string literals to be used as types in parameter type annotations. String literal types are permitted only in that context and nowhere else. +Specialized signatures (section [3.9.2.4](#3.9.2.4)) permit string literals to be used as types in parameter type annotations. String literal types are permitted only in that context and nowhere else. All string literal types are subtypes of the String primitive type. @@ -1061,26 +1190,26 @@ All string literal types are subtypes of the String primitive type. Object types are composed from properties, call signatures, construct signatures, and index signatures, collectively called members. -Class and interface type references, array types, tuple types, union types, function types, and constructor types are all classified as object types. Multiple constructs in the TypeScript language create object types, including: +Class and interface type references, array types, tuple types, function types, and constructor types are all classified as object types. Multiple constructs in the TypeScript language create object types, including: -* Object type literals (section [3.7.3](#3.7.3)). -* Array type literals (section [3.7.4](#3.7.4)). -* Tuple type literals (section [3.7.5](#3.7.5)). -* Function type literals (section [3.7.7](#3.7.7)). -* Constructor type literals (section [3.7.8](#3.7.8)). +* Object type literals (section [3.8.3](#3.8.3)). +* Array type literals (section [3.8.4](#3.8.4)). +* Tuple type literals (section [3.8.5](#3.8.5)). +* Function type literals (section [3.8.8](#3.8.8)). +* Constructor type literals (section [3.8.9](#3.8.9)). * Object literals (section [4.5](#4.5)). * Array literals (section [4.6](#4.6)). -* Function expressions (section [4.9](#4.9)) and function declarations ([6.1](#6.1)). +* Function expressions (section [4.10](#4.10)) and function declarations ([6.1](#6.1)). * Constructor function types created by class declarations (section [8.2.5](#8.2.5)). -* Module instance types created by module declarations (section [10.3](#10.3)). +* Namespace instance types created by namespace declarations (section [10.3](#10.3)). ### 3.3.1 Named Type References -Type references (section [3.7.2](#3.7.2)) to class and interface types are classified as object types. Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class or interface to produce an actual object type. +Type references (section [3.8.2](#3.8.2)) to class and interface types are classified as object types. Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class or interface to produce an actual object type. ### 3.3.2 Array Types -***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type 'Array' in the global module with the array element type as a type argument. Array type literals (section [3.7.4](#3.7.4)) provide a shorthand notation for creating such references. +***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type 'Array' in the global namespace with the array element type as a type argument. Array type literals (section [3.8.4](#3.8.4)) provide a shorthand notation for creating such references. The declaration of the 'Array' interface includes a property 'length' and a numeric index signature for the element type, along with other members: @@ -1098,11 +1227,11 @@ Array literals (section [4.6](#4.6)) may be used to create values of array types var a: string[] = ["hello", "world"]; ``` -A type is said to be an ***array-like type*** if it is assignable (section [3.10.4](#3.10.4)) to the type `any[]`. +A type is said to be an ***array-like type*** if it is assignable (section [3.11.4](#3.11.4)) to the type `any[]`. ### 3.3.3 Tuple Types -***Tuple types*** represent JavaScript arrays with individually tracked element types. Tuple types are written using tuple type literals (section [3.7.5](#3.7.5)). A tuple type combines a set of numerically named properties with the members of an array type. Specifically, a tuple type +***Tuple types*** represent JavaScript arrays with individually tracked element types. Tuple types are written using tuple type literals (section [3.8.5](#3.8.5)). A tuple type combines a set of numerically named properties with the members of an array type. Specifically, a tuple type ```TypeScript [ T0, T1, ..., Tn ] @@ -1143,11 +1272,11 @@ A type is said to be a ***tuple-like type*** if it has a property with the numer ### 3.3.4 Function Types -An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.7.7](#3.7.7)) or by including call signatures in object type literals. +An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.8.8](#3.8.8)) or by including call signatures in object type literals. ### 3.3.5 Constructor Types -An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.7.8](#3.7.8)) or by including construct signatures in object type literals. +An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.8.9](#3.8.9)) or by including construct signatures in object type literals. ### 3.3.6 Members @@ -1160,22 +1289,16 @@ Every object type is composed from zero or more of the following kinds of member Properties are either ***public***, ***private***, or ***protected*** and are either ***required*** or ***optional***: -* Properties in a class declaration may be designated public, private, or protected, while properties declared in other contexts are always considered public. Private members are only accessible within their declaring class, as described in section [8.2.2](#8.2.2), and private properties match only themselves in subtype and assignment compatibility checks, as described in section [3.10](#3.10). Protected members are only accessible within their declaring class and classes derived from it, as described in section [8.2.2](#8.2.2), and protected properties match only themselves and overrides in subtype and assignment compatibility checks, as described in section [3.10](#3.10). -* Properties in an object type literal or interface declaration may be designated required or optional, while properties declared in other contexts are always considered required. Properties that are optional in the target type of an assignment may be omitted from source objects, as described in section [3.10.4](#3.10.4). +* Properties in a class declaration may be designated public, private, or protected, while properties declared in other contexts are always considered public. Private members are only accessible within their declaring class, as described in section [8.2.2](#8.2.2), and private properties match only themselves in subtype and assignment compatibility checks, as described in section [3.11](#3.11). Protected members are only accessible within their declaring class and classes derived from it, as described in section [8.2.2](#8.2.2), and protected properties match only themselves and overrides in subtype and assignment compatibility checks, as described in section [3.11](#3.11). +* Properties in an object type literal or interface declaration may be designated required or optional, while properties declared in other contexts are always considered required. Properties that are optional in the target type of an assignment may be omitted from source objects, as described in section [3.11.4](#3.11.4). -Call and construct signatures may be ***specialized*** (section [3.8.2.4](#3.8.2.4)) by including parameters with string literal types. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. +Call and construct signatures may be ***specialized*** (section [3.9.2.4](#3.9.2.4)) by including parameters with string literal types. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. ## 3.4 Union Types -***Union types*** represent values that may have one of several disjoint representations. A value of a union type *A* | *B* is a value that is *either* of type *A* or type *B*. Union types are written using union type literals (section [3.7.6](#3.7.6)). +***Union types*** represent values that may have one of several distinct representations. A value of a union type *A* | *B* is a value that is *either* of type *A* or type *B*. Union types are written using union type literals (section [3.8.6](#3.8.6)). -A union type encompasses an unordered set of unrelated types (that is, types that aren't subtypes of each other). The following rules govern union types: - -* *A* | *B* is equivalent to *A* if *B* is a subtype of *A*. -* *A* | *B* is equivalent to *B* | *A*. -* *AB* | *C* is equivalent to *A* | *BC*, where *AB* is *A* | *B* and *BC* is *B* | *C*. - -Union types are reduced to the smallest possible set of constituent types using these rules. +A union type encompasses an ordered set of constituent types. While it is generally true that *A* | *B* is equivalent to *B* | *A*, the order of the constituent types may matter when determining the call and construct signatures of the union type. Union types have the following subtype relationships: @@ -1187,9 +1310,9 @@ Similarly, union types have the following assignability relationships: * A union type *U* is assignable to a type *T* if each type in *U* is assignable to *T*. * A type *T* is assignable to a union type *U* if *T* is assignable to any type in *U*. -The || and conditional operators (section [4.15.7](#4.15.7) and [4.16](#4.16)) may produce values of union types, and array literals (section [4.6](#4.6)) may produce array values that have union types as their element types. +The || and conditional operators (section [4.19.7](#4.19.7) and [4.20](#4.20)) may produce values of union types, and array literals (section [4.6](#4.6)) may produce array values that have union types as their element types. -Type guards (section [4.20](#4.20)) may be used to narrow a union type to a more specific type. In particular, type guards are useful for narrowing union type values to a non-union type values. +Type guards (section [4.24](#4.24)) may be used to narrow a union type to a more specific type. In particular, type guards are useful for narrowing union type values to a non-union type values. In the example @@ -1209,7 +1332,7 @@ it is possible to assign 'x' a value of type `string`, `number`, or the union ty var n = typeof x === "string" ? x.length : x; // Type of n is number ``` -For purposes of property access and function calls, the apparent members (section [3.10.1](#3.10.1)) of a union type *U* are those that are present in every one of its constituent types, with types that are unions of the respective apparent members in the constituent types. The following example illustrates the merging of member types that occurs when union types are created from object types. +For purposes of property access and function calls, the apparent members (section [3.11.1](#3.11.1)) of a union type are those that are present in every one of its constituent types, with types that are unions of the respective apparent members in the constituent types. The following example illustrates the merging of member types that occurs when union types are created from object types. ```TypeScript interface A { @@ -1231,25 +1354,71 @@ var c = x.c; // Error, no property c in union type Note that 'x.a' has a union type because the type of 'a' is different in 'A' and 'B', whereas 'x.b' simply has type number because that is the type of 'b' in both 'A' and 'B'. Also note that there is no property 'x.c' because only 'A' has a property 'c'. -### 3.4.1 Contextual Union Types +When used as a contextual type (section [4.23](#4.23)), a union type has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types. Specifically, a union type used as a contextual type has the apparent members defined in section [3.11.1](#3.11.1), except that a particular member need only be present in one or more constituent types instead of all constituent types. -When used as a contextual type (section [4.19](#4.19)), a union type *U* has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: +## 3.5 Intersection Types -* Let *S* be the set of types in *U* that has a property *P*. If *S* is not empty, *U* has a property *P* of a union type of the types of *P* from each type in *S*. -* Let *S* be the set of types in *U* that have call signatures. If *S* is not empty and the sets of call signatures of the types in *S* are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *S*. -* Let *S* be the set of types in *U* that have construct signatures. If *S* is not empty and the sets of construct signatures of the types in *S* are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *S*. -* Let *S* be the set of types in *U* that has a string index signature. If *S* is not empty, *U* has a string index signature of a union type of the types of the string index signatures from each type in *S*. -* Let *S* be the set of types in *U* that has a numeric index signature. If *S* is not empty, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *S*. +***Intersection types*** represent values that simultaneously have multiple types. A value of an intersection type *A* & *B* is a value that is *both* of type *A* and type *B*. Intersection types are written using intersection type literals (section [3.8.7](#3.8.7)). -## 3.5 Type Parameters +An intersection type encompasses an ordered set of constituent types. While it is generally true that *A* & *B* is equivalent to *B* & *A*, the order of the constituent types may matter when determining the call and construct signatures of the intersection type. + +Intersection types have the following subtype relationships: + +* An intersection type *I* is a subtype of a type *T* if any type in *I* is a subtype of *T*. +* A type *T* is a subtype of an intersection type *I* if *T* is a subtype of each type in *I*. + +Similarly, intersection types have the following assignability relationships: + +* An intersection type *I* is assignable to a type *T* if any type in *I* is assignable to *T*. +* A type *T* is assignable to an intersection type *I* if *T* is assignable to each type in *I*. + +For purposes of property access and function calls, the apparent members (section [3.11.1](#3.11.1)) of an intersection type are those that are present in one or more of its constituent types, with types that are intersections of the respective apparent members in the constituent types. The following examples illustrate the merging of member types that occurs when intersection types are created from object types. + +```TypeScript +interface A { a: number } +interface B { b: number } + +var ab: A & B = { a: 1, b: 1 }; +var a: A = ab; // A & B assignable to A +var b: B = ab; // A & B assignable to B + +interface X { p: A } +interface Y { p: B } + +var xy: X & Y = { p: ab }; // X & Y has property p of type A & B + +type F1 = (a: string, b: string) => void; +type F2 = (a: number, b: number) => void; + +var f: F1 & F2 = (a: string | number, b: string | number) => { }; +f("hello", "world"); // Ok +f(1, 2); // Ok +f(1, "test"); // Error +``` + +The union and intersection type operators can be applied to type parameters. This capability can for example be used to model functions that merge objects: + +```TypeScript +function extend(first: T, second: U): T & U { + // Extend first with properties of second +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; +``` + +It is possible to create intersection types for which no values other than null or undefined are possible. For example, intersections of primitive types such as `string & number` fall into this category. + +## 3.6 Type Parameters A type parameter represents an actual type that the parameter is bound to in a generic type reference or a generic function call. Type parameters have constraints that establish upper bounds for their actual type arguments. Since a type parameter represents a multitude of different type arguments, type parameters have certain restrictions compared to other types. In particular, a type parameter cannot be used as a base class or interface. -### 3.5.1 Type Parameter Lists +### 3.6.1 Type Parameter Lists -Class, interface, and function declarations may optionally include lists of type parameters enclosed in < and > brackets. Type parameters are also permitted in call signatures of object, function, and constructor type literals. +Class, interface, type alias, and function declarations may optionally include lists of type parameters enclosed in < and > brackets. Type parameters are also permitted in call signatures of object, function, and constructor type literals.   *TypeParameters:*    `<` *TypeParameterList* `>` @@ -1259,7 +1428,7 @@ Class, interface, and function declarations may optionally include lists of type    *TypeParameterList* `,` *TypeParameter*   *TypeParameter:* -   *Identifier* *Constraintopt* +   *BindingIdentifier* *Constraintopt*   *Constraint:*    `extends` *Type* @@ -1268,7 +1437,7 @@ Type parameter names must be unique. A compile-time error occurs if two or more The scope of a type parameter extends over the entire declaration with which the type parameter list is associated, with the exception of static member declarations in classes. -Each type parameter has an associated type parameter ***constraint*** that establishes an upper bound for type arguments. Omitting a constraint corresponds to specifying the empty object type `{}`. Type parameters declared in a particular type parameter list may not be referenced in constraints in that type parameter list. +Each type parameter has an associated type parameter ***constraint*** that establishes an upper bound for type arguments. Omitting a constraint or specifying type `any` as the constraint corresponds to specifying the empty object type `{}`. Type parameters declared in a particular type parameter list may not be referenced in constraints in that type parameter list. The ***base constraint*** of a type parameter *T* is defined as follows: @@ -1286,11 +1455,11 @@ interface G { the base constraint of 'T' is the empty object type, and the base constraint of 'U' and 'V' is 'Function'. -For purposes of determining type relationships (section [3.10](#3.10)), type parameters appear to be subtypes of their base constraint. Likewise, in property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)), type parameters appear to have the members of their base constraint, but no other members. +For purposes of determining type relationships (section [3.11](#3.11)), type parameters appear to be subtypes of their base constraint. Likewise, in property accesses (section [4.13](#4.13)), `new` operations (section [4.14](#4.14)), and function calls (section [4.15](#4.15)), type parameters appear to have the members of their base constraint, but no other members. -### 3.5.2 Type Argument Lists +### 3.6.2 Type Argument Lists -A type reference (section [3.7.2](#3.7.2)) to a generic type must include a list of type arguments enclosed in angle brackets and separated by commas. Similarly, a call (section [4.12](#4.12)) to a generic function may explicitly include a type argument list instead of relying on type inference. +A type reference (section [3.8.2](#3.8.2)) to a generic type must include a list of type arguments enclosed in angle brackets and separated by commas. Similarly, a call (section [4.15](#4.15)) to a generic function may explicitly include a type argument list instead of relying on type inference.   *TypeArguments:*    `<` *TypeArgumentList* `>` @@ -1302,7 +1471,7 @@ A type reference (section [3.7.2](#3.7.2)) to a generic type must include a list   *TypeArgument:*    *Type* -Type arguments correspond one-to-one with type parameters of the generic type or function being referenced. A type argument list is required to specify exactly one type argument for each corresponding type parameter, and each type argument is required to ***satisfy*** the constraint of its corresponding type parameter. A type argument satisfies a type parameter constraint if the type argument is assignable to (section [3.10.4](#3.10.4)) the constraint type once type arguments are substituted for type parameters. +Type arguments correspond one-to-one with type parameters of the generic type or function being referenced. A type argument list is required to specify exactly one type argument for each corresponding type parameter, and each type argument is required to ***satisfy*** the constraint of its corresponding type parameter. A type argument satisfies a type parameter constraint if the type argument is assignable to (section [3.11.4](#3.11.4)) the constraint type once type arguments are substituted for type parameters. Given the declaration @@ -1314,13 +1483,13 @@ a type reference of the form 'G<A, B>' places no requirements on 'A' but requ The process of substituting type arguments for type parameters in a generic type or generic signature is known as ***instantiating*** the generic type or signature. Instantiation of a generic type or signature can fail if the supplied type arguments do not satisfy the constraints of their corresponding type parameters. -## 3.6 Named Types +## 3.7 Named Types -Classes, interfaces, enums, and type aliases are ***named types*** that are introduced through class declarations (section [8.1](#8.1)), interface declarations (section [7.1](#7.1)), enum declarations ([9.1](#9.1)), and type alias declarations (section [3.9](#3.9)). Class and interface types may have type parameters and are then called ***generic types***. Conversely, named types without type parameters are called ***non-generic types***. +Classes, interfaces, enums, and type aliases are ***named types*** that are introduced through class declarations (section [8.1](#8.1)), interface declarations (section [7.1](#7.1)), enum declarations ([9.1](#9.1)), and type alias declarations (section [3.10](#3.10)). Classes, interfaces, and type aliases may have type parameters and are then called ***generic types***. Conversely, named types without type parameters are called ***non-generic types***. Interface declarations only introduce named types, whereas class declarations introduce named types *and* constructor functions that create instances of implementations of those named types. The named types introduced by class and interface declarations have only minor differences (classes can't declare optional members and interfaces can't declare private or protected members) and are in most contexts interchangeable. In particular, class declarations with only public members introduce named types that function exactly like those created by interface declarations. -Named types are referenced through ***type references*** (section [3.7.2](#3.7.2)) that specify a type name and, if applicable, the type arguments to be substituted for the type parameters of the named type. +Named types are referenced through ***type references*** (section [3.8.2](#3.8.2)) that specify a type name and, if applicable, the type arguments to be substituted for the type parameters of the named type. Named types are technically not types—only *references* to named types are. This distinction is particularly evident with generic types: Generic types are "templates" from which multiple *actual* types can be created by writing type references that supply type arguments to substitute in place of the generic type's type parameters. This substitution process is known as ***instantiating*** a generic type. Only once a generic type is instantiated does it denote an actual type. @@ -1342,7 +1511,7 @@ is indistinguishable from the type { first: string; second: Entity; } ``` -### 3.6.1 Instance Types +### 3.7.1 Instance Types Each class and interface has an associated actual type known as the ***instance type***. For a non-generic class or interface, the instance type is simply a type reference to the class or interface. For a generic class or interface, the instance type is an instantiation of the generic type where each of the type arguments is the corresponding type parameter. Since the instance type uses the type parameters it can be used only where the type parameters are in scope—that is, inside the declaration of the class or interface. Within the constructor and instance member functions of a class, the type of `this` is the instance type of the class. @@ -1357,18 +1526,22 @@ class G { // Introduce type parameter T } ``` -## 3.7 Specifying Types +## 3.8 Specifying Types Types are specified either by referencing their keyword or name, or by writing object type literals, array type literals, tuple type literals, function type literals, constructor type literals, or type queries.   *Type:* -   *PrimaryOrUnionType* +   *UnionOrIntersectionOrPrimaryType*    *FunctionType*    *ConstructorType* -  *PrimaryOrUnionType:* -   *PrimaryType* -   *UnionType* +  *UnionOrIntersectionOrPrimaryType:* +   *UnionType* +   *IntersectionOrPrimaryType* + +  *IntersectionOrPrimaryType:* +   *IntersectionType* +   *PrimaryType*   *PrimaryType:*    *ParenthesizedType* @@ -1382,29 +1555,31 @@ Types are specified either by referencing their keyword or name, or by writing o   *ParenthesizedType:*    `(` *Type* `)` -Parentheses are required around union, function, or constructor types when they are used as array element types, and parentheses are required around function or constructor types in union types. For example: +Parentheses are required around union, intersection, function, or constructor types when they are used as array element types; around union, function, or constructor types in intersection types; and around function or constructor types in union types. For example: ```TypeScript (string | number)[] -((x: string) => string) | ((x: number) => number) +((x: string) => string) | ((x: number) => number) +(A | B) & (C | D) ``` The different forms of type notations are described in the following sections. -### 3.7.1 Predefined Types +### 3.8.1 Predefined Types -The `any`, `number`, `boolean`, `string`, and `void` keywords reference the Any type and the Number, Boolean, String, and Void primitive types respectively. +The `any`, `number`, `boolean`, `string`, `symbol` and `void` keywords reference the Any type and the Number, Boolean, String, Symbol, and Void primitive types respectively.   *PredefinedType:*    `any`    `number`    `boolean`    `string` +   `symbol`    `void` The predefined type keywords are reserved and cannot be used as names of user defined types. -### 3.7.2 Type References +### 3.8.2 Type References A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. @@ -1412,24 +1587,26 @@ A type reference references a named type or type parameter through its name and,    *TypeName* *[no LineTerminator here]* *TypeArgumentsopt*   *TypeName:* -   *Identifier* -   *ModuleName* `.` *Identifier* +   *IdentifierReference* +   *NamespaceName* `.` *IdentifierReference* -  *ModuleName:* -   *Identifier* -   *ModuleName* `.` *Identifier* +  *NamespaceName:* +   *IdentifierReference* +   *NamespaceName* `.` *IdentifierReference* -A *TypeReference* consists of a *TypeName* that a references a named type or type parameter. A reference to a generic type must be followed by a list of *TypeArguments* (section [3.5.2](#3.5.2)). +A *TypeReference* consists of a *TypeName* that a references a named type or type parameter. A reference to a generic type must be followed by a list of *TypeArguments* (section [3.6.2](#3.6.2)). + +A *TypeName* is either a single identifier or a sequence of identifiers separated by dots. In a type name, all identifiers but the last one refer to namespaces and the last identifier refers to a named type. Resolution of a *TypeName* consisting of a single identifier is described in section [2.4](#2.4). -Resolution of a *TypeName* of the form *M.N*, where *M* is a *ModuleName* and *N* is an *Identifier*, proceeds by first resolving the module name *M*. If the resolution of *M* is successful and the resulting module contains an exported named type *N*, then *M.N* refers to that member. Otherwise, *M.N* is undefined. +Resolution of a *TypeName* of the form *N.X*, where *N* is a *NamespaceName* and *X* is an *IdentifierReference*, proceeds by first resolving the namespace name *N*. If the resolution of *N* is successful and the export member set (sections [10.4](#10.4) and [11.3.4.4](#11.3.4.4)) of the resulting namespace contains a named type *X*, then *N.X* refers to that member. Otherwise, *N.X* is undefined. -Resolution of a *ModuleName* consisting of a single identifier is described in section [2.4](#2.4). +Resolution of a *NamespaceName* consisting of a single identifier is described in section [2.4](#2.4). Identifiers declared in namespace declarations (section [10.1](#10.1)) or import declarations (sections [10.3](#10.3), [11.3.2](#11.3.2), and [11.3.3](#11.3.3)) may be classified as namespaces. -Resolution of a *ModuleName* of the form *M.N*, where *M* is a *ModuleName* and *N* is an *Identifier*, proceeds by first resolving the module name *M*. If the resolution of *M* is successful and the resulting module contains an exported module member *N*, then *M.N* refers to that member. Otherwise, *M.N* is undefined. +Resolution of a *NamespaceName* of the form *N.X*, where *N* is a *NamespaceName* and *X* is an *IdentifierReference*, proceeds by first resolving the namespace name *N*. If the resolution of *N* is successful and the export member set (sections [10.4](#10.4) and [11.3.4.4](#11.3.4.4)) of the resulting namespace contains an exported namespace member *X*, then *N.X* refers to that member. Otherwise, *N.X* is undefined. -A type reference to a generic type is required to specify exactly one type argument for each type parameter of the referenced generic type, and each type argument must be assignable to (section [3.10.4](#3.10.4)) the constraint of the corresponding type parameter or otherwise an error occurs. An example: +A type reference to a generic type is required to specify exactly one type argument for each type parameter of the referenced generic type, and each type argument must be assignable to (section [3.11.4](#3.11.4)) the constraint of the corresponding type parameter or otherwise an error occurs. An example: ```TypeScript interface A { a: string; } @@ -1454,7 +1631,7 @@ var v7: G; // Error, no arguments A type argument is simply a *Type* and may itself be a type reference to a generic type, as demonstrated by 'v4' in the example above. -As described in section [3.6](#3.6), a type reference to a generic type *G* designates a type wherein all occurrences of *G*'s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of 'v1' above is equivalent to: +As described in section [3.7](#3.7), a type reference to a generic type *G* designates a type wherein all occurrences of *G*'s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of 'v1' above is equivalent to: ```TypeScript var v1: { @@ -1463,7 +1640,7 @@ var v1: { }; ``` -### 3.7.3 Object Type Literals +### 3.8.3 Object Type Literals An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. Object type literals can be given names using interface declarations but are otherwise anonymous. @@ -1471,11 +1648,13 @@ An object type literal defines an object type by specifying the set of members t    `{` *TypeBodyopt* `}`   *TypeBody:* -   *TypeMemberList* `;`*opt* +   *TypeMemberList* `;`*opt* +   *TypeMemberList* `,`*opt*   *TypeMemberList:*    *TypeMember* -   *TypeMemberList* `;` *TypeMember* +   *TypeMemberList* `;` *TypeMember* +   *TypeMemberList* `,` *TypeMember*   *TypeMember:*    *PropertySignature* @@ -1484,18 +1663,18 @@ An object type literal defines an object type by specifying the set of members t    *IndexSignature*    *MethodSignature* -The members of an object type literal are specified as a combination of property, call, construct, index, and method signatures. Object type members are described in section [3.8](#3.8). +The members of an object type literal are specified as a combination of property, call, construct, index, and method signatures. Object type members are described in section [3.9](#3.9). -### 3.7.4 Array Type Literals +### 3.8.4 Array Type Literals An array type literal is written as an element type followed by an open and close square bracket.   *ArrayType:*    *PrimaryType* *[no LineTerminator here]* `[` `]` -An array type literal references an array type (section [3.3.2](#3.3.2)) with the given element type. An array type literal is simply shorthand notation for a reference to the generic interface type 'Array' in the global module with the element type as a type argument. +An array type literal references an array type (section [3.3.2](#3.3.2)) with the given element type. An array type literal is simply shorthand notation for a reference to the generic interface type 'Array' in the global namespace with the element type as a type argument. -When union, function, or constructor types are used as array element types they must be enclosed in parentheses. For example: +When union, intersection, function, or constructor types are used as array element types they must be enclosed in parentheses. For example: ```TypeScript (string | number)[] @@ -1509,7 +1688,7 @@ Array Array<() => string> ``` -### 3.7.5 Tuple Type Literals +### 3.8.5 Tuple Type Literals A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. @@ -1525,28 +1704,25 @@ A tuple type literal is written as a sequence of element types, separated by com A tuple type literal references a tuple type (section [3.3.3](#3.3.3)). -### 3.7.6 Union Type Literals +### 3.8.6 Union Type Literals A union type literal is written as a sequence of types separated by vertical bars.   *UnionType:* -   *PrimaryOrUnionType* `|` *PrimaryType* +   *UnionOrIntersectionOrPrimaryType* `|` *IntersectionOrPrimaryType* A union typle literal references a union type (section [3.4](#3.4)). -When function or constructor types are included in union types they must be enclosed in parentheses. For example: +### 3.8.7 Intersection Type Literals -```TypeScript -((x: string) => string) | ((x: number) => number) -``` +An intersection type literal is written as a sequence of types separated by ampersands. -Alternatively, function or constructor types in union types can be written using object literals: +  *IntersectionType:* +   *IntersectionOrPrimaryType* `&` *PrimaryType* -```TypeScript -{ (x: string): string } | { (x: number): number } -``` +An intersection typle literal references an intersection type (section [3.5](#3.5)). -### 3.7.7 Function Type Literals +### 3.8.8 Function Type Literals A function type literal specifies the type parameters, regular parameters, and return type of a call signature. @@ -1567,7 +1743,7 @@ is exactly equivalent to the object type literal Note that function types with multiple call or construct signatures cannot be written as function type literals but must instead be written as object type literals. -### 3.7.8 Constructor Type Literals +### 3.8.9 Constructor Type Literals A constructor type literal specifies the type parameters, regular parameters, and return type of a construct signature. @@ -1588,7 +1764,7 @@ is exactly equivalent to the object type literal Note that constructor types with multiple construct signatures cannot be written as constructor type literals but must instead be written as object type literals. -### 3.7.9 Type Queries +### 3.8.10 Type Queries A type query obtains the type of an expression. @@ -1596,12 +1772,12 @@ A type query obtains the type of an expression.    `typeof` *TypeQueryExpression*   *TypeQueryExpression:* -   *Identifier* +   *IdentifierReference*    *TypeQueryExpression* `.` *IdentifierName* -A type query consists of the keyword `typeof` followed by an expression. The expression is restricted to a single identifier or a sequence of identifiers separated by periods. The expression is processed as an identifier expression (section [4.3](#4.3)) or property access expression (section [4.10](#4.10)), the widened type (section [3.11](#3.11)) of which becomes the result. Similar to other static typing constructs, type queries are erased from the generated JavaScript code and add no run-time overhead. +A type query consists of the keyword `typeof` followed by an expression. The expression is restricted to a single identifier or a sequence of identifiers separated by periods. The expression is processed as an identifier expression (section [4.3](#4.3)) or property access expression (section [4.13](#4.13)), the widened type (section [3.12](#3.12)) of which becomes the result. Similar to other static typing constructs, type queries are erased from the generated JavaScript code and add no run-time overhead. -Type queries are useful for capturing anonymous types that are generated by various constructs such as object literals, function declarations, and module declarations. For example: +Type queries are useful for capturing anonymous types that are generated by various constructs such as object literals, function declarations, and namespace declarations. For example: ```TypeScript var a = { x: 10, y: 20 }; @@ -1628,48 +1804,44 @@ var h: () => typeof h; Here, 'g' and 'g.x' have the same recursive type, and likewise 'h' and 'h()' have the same recursive type. -## 3.8 Specifying Members +## 3.9 Specifying Members -The members of an object type literal (section [3.7.3](#3.7.3)) are specified as a combination of property, call, construct, index, and method signatures. +The members of an object type literal (section [3.8.3](#3.8.3)) are specified as a combination of property, call, construct, index, and method signatures. -### 3.8.1 Property Signatures +### 3.9.1 Property Signatures A property signature declares the name and type of a property member.   *PropertySignature:*    *PropertyName* `?`*opt* *TypeAnnotationopt* -  *PropertyName:* -   *IdentifierName* -   *StringLiteral* -   *NumericLiteral* +  *TypeAnnotation:* +   `:` *Type* -The *PropertyName* production, reproduced above from the ECMAScript grammar, permits a property name to be any identifier (including a reserved word), a string literal, or a numeric literal. String literals can be used to give properties names that are not valid identifiers, such as names containing blanks. Numeric literal property names are equivalent to string literal property names with the string representation of the numeric literal, as defined in the ECMAScript specification. - -The *PropertyName* of a property signature must be unique within its containing type. If the property name is followed by a question mark, the property is optional. Otherwise, the property is required. +The *PropertyName* ([2.2.2](#2.2.2)) of a property signature must be unique within its containing type, and must denote a well-known symbol if it is a computed property name ([2.2.3](#2.2.3)). If the property name is followed by a question mark, the property is optional. Otherwise, the property is required. If a property signature omits a *TypeAnnotation*, the Any type is assumed. -### 3.8.2 Call Signatures +### 3.9.2 Call Signatures -A call signature defines the type parameters, parameter list, and return type associated with applying a call operation (section [4.12](#4.12)) to an instance of the containing type. A type may ***overload*** call operations by defining multiple different call signatures. +A call signature defines the type parameters, parameter list, and return type associated with applying a call operation (section [4.15](#4.15)) to an instance of the containing type. A type may ***overload*** call operations by defining multiple different call signatures.   *CallSignature:*    *TypeParametersopt* `(` *ParameterListopt* `)` *TypeAnnotationopt* -A call signature that includes *TypeParameters* (section [3.5.1](#3.5.1)) is called a ***generic call signature***. Conversely, a call signature with no *TypeParameters* is called a non-generic call signature. +A call signature that includes *TypeParameters* (section [3.6.1](#3.6.1)) is called a ***generic call signature***. Conversely, a call signature with no *TypeParameters* is called a non-generic call signature. -As well as being members of object type literals, call signatures occur in method signatures (section [3.8.5](#3.8.5)), function expressions (section [4.9](#4.9)), and function declarations (section [6.1](#6.1)). +As well as being members of object type literals, call signatures occur in method signatures (section [3.9.5](#3.9.5)), function expressions (section [4.10](#4.10)), and function declarations (section [6.1](#6.1)). An object type containing call signatures is said to be a ***function type***. -#### 3.8.2.1 Type Parameters +#### 3.9.2.1 Type Parameters -Type parameters (section [3.5.1](#3.5.1)) in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. For example, a signature might introduce a type parameter and use it as both a parameter type and a return type, in effect describing a function that returns a value of the same type as its argument. +Type parameters (section [3.6.1](#3.6.1)) in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. For example, a signature might introduce a type parameter and use it as both a parameter type and a return type, in effect describing a function that returns a value of the same type as its argument. Type parameters may be referenced in parameter types and return type annotations, but not in type parameter constraints, of the call signature in which they are introduced. -Type arguments (section [3.5.2](#3.5.2)) for call signature type parameters may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. An ***instantiation*** of a generic call signature for a particular set of type arguments is the call signature formed by replacing each type parameter with its corresponding type argument. +Type arguments (section [3.6.2](#3.6.2)) for call signature type parameters may be explicitly specified in a call operation or may, when possible, be inferred (section [4.15.2](#4.15.2)) from the types of the regular arguments in the call. An ***instantiation*** of a generic call signature for a particular set of type arguments is the call signature formed by replacing each type parameter with its corresponding type argument. Some examples of call signatures with type parameters follow below. @@ -1697,7 +1869,7 @@ A function taking an array of one type and a function argument, returning an arr (a: T[], f: (x: T) => U): U[] ``` -#### 3.8.2.2 Parameter List +#### 3.9.2.2 Parameter List A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, finally followed by an optional rest parameter. @@ -1715,16 +1887,16 @@ A signature's parameter list consists of zero or more required parameters, follo    *RequiredParameterList* `,` *RequiredParameter*   *RequiredParameter:* -   *AccessibilityModifieropt* *IdentifierOrPattern* *TypeAnnotationopt* -   *Identifier* `:` *StringLiteral* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* *TypeAnnotationopt* +   *BindingIdentifier* `:` *StringLiteral*   *AccessibilityModifier:*    `public`    `private`    `protected` -  *IdentifierOrPattern:* -   *Identifier* +  *BindingIdentifierOrPattern:* +   *BindingIdentifier*    *BindingPattern*   *OptionalParameterList:* @@ -1732,20 +1904,20 @@ A signature's parameter list consists of zero or more required parameters, follo    *OptionalParameterList* `,` *OptionalParameter*   *OptionalParameter:* -   *AccessibilityModifieropt* *IdentifierOrPattern* `?` *TypeAnnotationopt* -   *AccessibilityModifieropt* *IdentifierOrPattern* *TypeAnnotationopt* *Initialiser* -   *Identifier* `?` `:` *StringLiteral* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* `?` *TypeAnnotationopt* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* *TypeAnnotationopt* *Initializer* +   *BindingIdentifier* `?` `:` *StringLiteral*   *RestParameter:* -   `...` *Identifier* *TypeAnnotationopt* +   `...` *BindingIdentifier* *TypeAnnotationopt* -A parameter declaration may specify either an identifier or a binding pattern ([5.1.2](#5.1.2)). The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. +A parameter declaration may specify either an identifier or a binding pattern ([5.2.2](#5.2.2)). The identifiers specified in parameter declarations and binding patterns in a parameter list must be unique within that parameter list. The type of a parameter in a signature is determined as follows: * If the declaration includes a type annotation, the parameter is of that type. -* Otherwise, if the declaration includes an initializer expression (which is permitted only when the parameter list occurs in conjunction with a function body), the parameter type is the widened form (section [3.11](#3.11)) of the type of the initializer expression. -* Otherwise, if the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section [5.1.3](#5.1.3)). +* Otherwise, if the declaration includes an initializer expression (which is permitted only when the parameter list occurs in conjunction with a function body), the parameter type is the widened form (section [3.12](#3.12)) of the type of the initializer expression. +* Otherwise, if the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section [5.2.3](#5.2.3)). * Otherwise, if the parameter is a rest parameter, the parameter type is `any[]`. * Otherwise, the parameter type is `any`. @@ -1753,11 +1925,13 @@ A parameter is permitted to include a `public`, `private`, or `protected` modifi A type annotation for a rest parameter must denote an array type. -When a parameter type annotation specifies a string literal type, the containing signature is a specialized signature (section [3.8.2.4](#3.8.2.4)). Specialized signatures are not permitted in conjunction with a function body, i.e. the *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, and *ConstructorImplementation* grammar productions do not permit parameters with string literal types. +When a parameter type annotation specifies a string literal type, the containing signature is a specialized signature (section [3.9.2.4](#3.9.2.4)). Specialized signatures are not permitted in conjunction with a function body, i.e. the *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, and *ConstructorImplementation* grammar productions do not permit parameters with string literal types. A parameter can be marked optional by following its name or binding pattern with a question mark (`?`) or by including an initializer. Initializers (including binding property or element initializers) are permitted only when the parameter list occurs in conjunction with a function body, i.e. only in a *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, or *ConstructorImplementation* grammar production. -#### 3.8.2.3 Return Type +*TODO: Update to reflect [binding parameter cannot be optional in implementation signature](https://github.com/Microsoft/TypeScript/issues/2797)*. + +#### 3.9.2.3 Return Type If present, a call signature's return type annotation specifies the type of the value computed and returned by a call operation. A `void` return type annotation is used to indicate that a function has no return value. @@ -1765,9 +1939,9 @@ When a call signature with no return type annotation occurs in a context without When a call signature with no return type annotation occurs in a context that has a function body (specifically, a function implementation, a member function implementation, or a member accessor declaration), the return type is inferred from the function body as described in section [6.3](#6.3). -#### 3.8.2.4 Specialized Signatures +#### 3.9.2.4 Specialized Signatures -When a parameter type annotation specifies a string literal type (section [3.2.8](#3.2.8)), the containing signature is considered a specialized signature. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. For example, the declaration +When a parameter type annotation specifies a string literal type (section [3.2.9](#3.2.9)), the containing signature is considered a specialized signature. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. For example, the declaration ```TypeScript interface Document { @@ -1780,13 +1954,13 @@ interface Document { states that calls to 'createElement' with the string literals "div", "span", and "canvas" return values of type 'HTMLDivElement', 'HTMLSpanElement', and 'HTMLCanvasElement' respectively, and that calls with all other string expressions return values of type 'HTMLElement'. -When writing overloaded declarations such as the one above it is important to list the non-specialized signature last. This is because overload resolution (section [4.12.1](#4.12.1)) processes the candidates in declaration order and picks the first one that matches. +When writing overloaded declarations such as the one above it is important to list the non-specialized signature last. This is because overload resolution (section [4.15.1](#4.15.1)) processes the candidates in declaration order and picks the first one that matches. Every specialized call or construct signature in an object type must be assignable to at least one non-specialized call or construct signature in the same object type (where a call signature *A* is considered assignable to another call signature *B* if an object type containing only *A* would be assignable to an object type containing only *B*). For example, the 'createElement' property in the example above is of a type that contains three specialized signatures, all of which are assignable to the non-specialized signature in the type. -### 3.8.3 Construct Signatures +### 3.9.3 Construct Signatures -A construct signature defines the parameter list and return type associated with applying the `new` operator (section [4.11](#4.11)) to an instance of the containing type. A type may overload `new` operations by defining multiple construct signatures with different parameter lists. +A construct signature defines the parameter list and return type associated with applying the `new` operator (section [4.14](#4.14)) to an instance of the containing type. A type may overload `new` operations by defining multiple construct signatures with different parameter lists.   *ConstructSignature:*    `new` *TypeParametersopt* `(` *ParameterListopt* `)` *TypeAnnotationopt* @@ -1795,33 +1969,33 @@ The type parameters, parameter list, and return type of a construct signature ar A type containing construct signatures is said to be a ***constructor type***. -### 3.8.4 Index Signatures +### 3.9.4 Index Signatures An index signature defines a type constraint for properties in the containing type.   *IndexSignature:* -   `[` *Identifier* `:` `string` `]` *TypeAnnotation* -   `[` *Identifier* `:` `number` `]` *TypeAnnotation* +   `[` *BindingIdentifier* `:` `string` `]` *TypeAnnotation* +   `[` *BindingIdentifier* `:` `number` `]` *TypeAnnotation* There are two kinds of index signatures: * ***String index signatures***, specified using index type `string`, define type constraints for all properties and numeric index signatures in the containing type. Specifically, in a type with a string index signature of type *T*, all properties and numeric index signatures must have types that are assignable to *T*. * ***Numeric index signatures***, specified using index type `number`, define type constraints for all numerically named properties in the containing type. Specifically, in a type with a numeric index signature of type *T*, all numerically named properties must have types that are assignable to *T*. -A ***numerically named property*** is a property whose name is a valid numeric literal. Specifically, a property with a name *N* for which ToNumber(*N*) is not NaN, where ToNumber is the abstract operation defined in ECMAScript specification. +A ***numerically named property*** is a property whose name is a valid numeric literal. Specifically, a property with a name *N* for which ToString(ToNumber(*N*)) is identical to *N*, where ToString and ToNumber are the abstract operations defined in ECMAScript specification. An object type can contain at most one string index signature and one numeric index signature. -Index signatures affect the determination of the type that results from applying a bracket notation property access to an instance of the containing type, as described in section [4.10](#4.10). +Index signatures affect the determination of the type that results from applying a bracket notation property access to an instance of the containing type, as described in section [4.13](#4.13). -### 3.8.5 Method Signatures +### 3.9.5 Method Signatures A method signature is shorthand for declaring a property of a function type.   *MethodSignature:*    *PropertyName* `?`*opt* *CallSignature* -If the identifier is followed by a question mark, the property is optional. Otherwise, the property is required. Only object type literals and interfaces can declare optional properties. +If the *PropertyName* is a computed property name ([2.2.3](#2.2.3)), it must specify a well-known symbol. If the *PropertyName* is followed by a question mark, the property is optional. Otherwise, the property is required. Only object type literals and interfaces can declare optional properties. A method signature of the form @@ -1878,24 +2052,26 @@ the properties 'func1', 'func2', and 'func3' are all of the same type, namely an the properties 'func4' and 'func5' are of the same type, namely an object type with two call signatures taking and returning number and string respectively. -## 3.9 Type Aliases +## 3.10 Type Aliases -A type alias declaration introduces a ***type alias*** in the containing module. +A type alias declaration introduces a ***type alias*** in the containing declaration space.   *TypeAliasDeclaration:* -   `type` *Identifier* `=` *Type* `;` +   `type` *BindingIdentifier* *TypeParametersopt* `=` *Type* `;` -A type alias serves as an alias for the type specified in the type alias declaration. Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive types and union types. +A type alias serves as an alias for the type specified in the type alias declaration. Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types. -Type aliases are referenced using type references ([3.7.2](#3.7.2)). Writing a reference to a type alias has ***exactly*** the same effect as writing the aliased type itself. +A type alias may optionally have type parameters (section [3.6.1](#3.6.1)) that serve as placeholders for actual types to be provided when the type alias is referenced in type references. A type alias with type parameters is called a ***generic type alias***. The type parameters of a generic type alias declaration are in scope and may be referenced in the aliased *Type*. -The *Identifier* of a type alias declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). +Type aliases are referenced using type references ([3.8.2](#3.8.2)). Type references to generic type aliases produce instantiations of the aliased type with the given type arguments. Writing a reference to a non-generic type alias has exactly the same effect as writing the aliased type itself, and writing a reference to a generic type alias has exactly the same effect as writing the resulting instantiation of the aliased type. + +The *BindingIdentifier* of a type alias declaration may not be one of the predefined type names (section [3.8.1](#3.8.1)). It is an error for the type specified in a type alias to depend on that type alias. Types have the following dependencies: * A type alias *directly depends on* the type it aliases. * A type reference *directly depends on* the referenced type and each of the type arguments, if any. -* A union type *directly depends on* each of the constituent types. +* A union or intersection type *directly depends on* each of the constituent types. * An array type *directly depends on* its element type. * A tuple type *directly depends on* each of its element types. * A type query *directly depends on* the type of the referenced entity. @@ -1907,11 +2083,12 @@ Some examples of type alias declarations: ```TypeScript type StringOrNumber = string | number; type Text = string | { text: string }; -type Coordinates = [number, number]; type NameLookup = Dictionary; -type Callback = (data: string) => void; -type RecFunc = () => RecFunc; -type ObjectStatics = typeof Object; +type ObjectStatics = typeof Object; +type Callback = (data: T) => void; +type Pair = [T, T]; +type Coordinates = Pair; +type Tree = T | { left: Tree, right: Tree }; ``` Interface types have many similarities to type aliases for object type literals, but since interface types offer more capabilities they are generally preferred to type aliases. For example, the interface type @@ -1936,29 +2113,34 @@ However, doing so means the following capabilities are lost: * An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. * An interface can have multiple merged declarations, but a type alias for an object type literal cannot. -* An interface can have type parameters, but a type alias for an object type literal cannot. -## 3.10 Type Relationships +## 3.11 Type Relationships Types in TypeScript have identity, subtype, supertype, and assignment compatibility relationships as defined in the following sections. -### 3.10.1 Apparent Members +### 3.11.1 Apparent Members -The ***apparent members*** of a type are the members observed in subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)). The apparent members of a type are determined as follows: +The ***apparent members*** of a type are the members observed in subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.13](#4.13)), `new` operations (section [4.14](#4.14)), and function calls (section [4.15](#4.15)). The apparent members of a type are determined as follows: * The apparent members of the primitive types Number, Boolean, and String are the apparent members of the global interface types 'Number', 'Boolean', and 'String' respectively. * The apparent members of an enum type are the apparent members of the global interface type 'Number'. -* The apparent members of a type parameter are the apparent members of the base constraint (section [3.5.1](#3.5.1)) of that type parameter. +* The apparent members of a type parameter are the apparent members of the constraint (section [3.6.1](#3.6.1)) of that type parameter. * The apparent members of an object type *T* are the combination of the following: * The declared and/or inherited members of *T*. * The properties of the global interface type 'Object' that aren't hidden by properties with the same name in *T*. * If *T* has one or more call or construct signatures, the properties of the global interface type 'Function' that aren't hidden by properties with the same name in *T*. * The apparent members of a union type *U* are determined as follows: - * If each type in *U* has an apparent property *P*, *U* has an apparent property *P* of a union type of the types of *P* from each type in *U*. - * If each type in *U* has apparent call signatures and the sets of apparent call signatures are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective apparent call signatures from each type in *U*. - * If each type in *U* has apparent construct signatures and the sets of apparent construct signatures are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective apparent construct signatures from each type in *U*. - * If each type in *U* has an apparent string index signature, *U* has a string index signature of a union type of the types of the apparent string index signatures from each type in *U*. - * If each type in *U* has an apparent numeric index signature, *U* has a numeric index signature of a union type of the types of the apparent numeric index signatures from each type in *U*. + * When all constituent types of *U* have an apparent property named *N*, *U* has an apparent property named *N* of a union type of the respective property types. + * When all constituent types of *U* have an apparent call signature with a parameter list *P*, *U* has an apparent call signature with the parameter list *P* and a return type that is a union of the respective return types. The call signatures appear in the same order as in the first constituent type. + * When all constituent types of *U* have an apparent construct signature with a parameter list *P*, *U* has an apparent construct signature with the parameter list *P* and a return type that is a union of the respective return types. The construct signatures appear in the same order as in the first constituent type. + * When all constituent types of *U* have an apparent string index signature, *U* has an apparent string index signature of a union type of the respective string index signature types. + * When all constituent types of *U* have an apparent numeric index signature, *U* has an apparent numeric index signature of a union type of the respective numeric index signature types. +* The apparent members of an intersection type *I* are determined as follows: + * When one of more constituent types of *I* have an apparent property named *N*, *I* has an apparent property named *N* of an intersection type of the respective property types. + * When one or more constituent types of *I* have a call signature *S*, *I* has the apparent call signature *S*. The signatures are ordered as a concatenation of the signatures of each constituent type in the order of the constituent types within *I*. + * When one or more constituent types of *I* have a construct signature *S*, *I* has the apparent construct signature *S*. The signatures are ordered as a concatenation of the signatures of each constituent type in the order of the constituent types within *I*. + * When one or more constituent types of *I* have an apparent string index signature, *I* has an apparent string index signature of an intersection type of the respective string index signature types. + * When one or more constituent types of *I* have an apparent numeric index signature, *I* has an apparent numeric index signature of an intersection type of the respective numeric index signature types. If a type is not one of the above, it is considered to have no apparent members. @@ -1974,7 +2156,7 @@ var err: Object = { toString: 0 }; // Error The last assignment is an error because the object literal has a 'toString' method that isn't compatible with that of 'Object'. -### 3.10.2 Type and Member Identity +### 3.11.2 Type and Member Identity Two types are considered ***identical*** when @@ -1982,6 +2164,7 @@ Two types are considered ***identical*** when * they are the same primitive type, * they are the same type parameter, * they are union types with identical sets of constituent types, or +* they are intersection types with identical sets of constituent types, or * they are object types with identical sets of members. Two members are considered identical when @@ -2011,9 +2194,9 @@ var b: C; the variables 'a' and 'b' are of identical types because the two type references to 'C' create types with a private member 'x' that originates in the same declaration, and because the two private 'x' members have types with identical sets of members once the type arguments 'X' and 'Y' are substituted. -### 3.10.3 Subtypes and Supertypes +### 3.11.3 Subtypes and Supertypes -*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if one of the following is true: +*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if *S* has no excess properties with respect to *T* ([3.11.5](#3.11.5)) and one of the following is true: * *S* and *T* are identical types. * *T* is the Any type. @@ -2021,10 +2204,12 @@ the variables 'a' and 'b' are of identical types because the two type references * *S* is the Null type and *T* is not the Undefined type. * *S* is an enum type and *T* is the primitive type Number. * *S* is a string literal type and *T* is the primitive type String. -* *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is a subtype of *T*. +* *S* is an intersection type and at least one constituent type of *S* is a subtype of *T*. * *T* is a union type and *S* is a subtype of at least one constituent type of *T*. -* *S* is an object type, a type parameter, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: +* *T* is an intersection type and *S* is a subtype of each constituent type of *T*. +* *S* is a type parameter and the constraint of *S* is a subtype of *T*. +* *S* is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: * *M* is a property and *S* has an apparent property *N* where * *M* and *N* have the same name, * the type of *N* is a subtype of that of *M*, @@ -2035,20 +2220,20 @@ the variables 'a' and 'b' are of identical types because the two type references * *M* has a rest parameter or the number of non-optional parameters in *N* is less than or equal to the total number of parameters in *M*, * for parameter positions that are present in both signatures, each parameter type in *N* is a subtype or supertype of the corresponding parameter type in *M*, and * the result type of *M* is Void, or the result type of *N* is a subtype of that of *M*. - * *M* is a string index signature of type *U* and *S* has an apparent string index signature of a type that is a subtype of *U*. - * *M* is a numeric index signature of type *U* and *S* has an apparent string or numeric index signature of a type that is a subtype of *U*. + * *M* is a string index signature of type *U*, and *U* is the Any type or *S* has an apparent string index signature of a type that is a subtype of *U*. + * *M* is a numeric index signature of type *U*, and *U* is the Any type or *S* has an apparent string or numeric index signature of a type that is a subtype of *U*. When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. -Note that specialized call and construct signatures (section [3.8.2.4](#3.8.2.4)) are not significant when determining subtype and supertype relationships. +Note that specialized call and construct signatures (section [3.9.2.4](#3.9.2.4)) are not significant when determining subtype and supertype relationships. Also note that type parameters are not considered object types. Thus, the only subtypes of a type parameter *T* are *T* itself and other type parameters that are directly or indirectly constrained to *T*. -### 3.10.4 Assignment Compatibility +### 3.11.4 Assignment Compatibility Types are required to be assignment compatible in certain circumstances, such as expression and variable types in assignment statements and argument and parameter types in function calls. -*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if one of the following is true: +*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if *S* has no excess properties with respect to *T* ([3.11.5](#3.11.5)) and one of the following is true: * *S* and *T* are identical types. * *S* or *T* is the Any type. @@ -2056,10 +2241,12 @@ Types are required to be assignment compatible in certain circumstances, such as * *S* is the Null type and *T* is not the Undefined type. * *S* or *T* is an enum type and* *the other is the primitive type Number. * *S* is a string literal type and *T* is the primitive type String. -* *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is assignable to *T*. +* *S* is an intersection type and at least one constituent type of *S* is assignable to *T*. * *T* is a union type and *S* is assignable to at least one constituent type of *T*. -* *S* is an object type, a type parameter, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: +* *T* is an intersection type and *S* is assignable to each constituent type of *T*. +* *S* is a type parameter and the constraint of *S* is assignable to *T*. +* *S* is an object type, an intersection type, an enum type, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: * *M* is a property and *S* has an apparent property *N* where * *M* and *N* have the same name, * the type of *N* is assignable to that of *M*, @@ -2076,7 +2263,7 @@ Types are required to be assignment compatible in certain circumstances, such as When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. -Note that specialized call and construct signatures (section [3.8.2.4](#3.8.2.4)) are not significant when determining assignment compatibility. +Note that specialized call and construct signatures (section [3.9.2.4](#3.9.2.4)) are not significant when determining assignment compatibility. The assignment compatibility and subtyping rules differ only in that @@ -2095,23 +2282,80 @@ foo({ id: 1234, name: false }); // Error, name of wrong type foo({ name: "hello" }); // Error, id required but missing ``` -### 3.10.5 Contextual Signature Instantiation +### 3.11.5 Excess Properties -During type argument inference in a function call (section [4.12.2](#4.12.2)) it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. A generic call signature *A* is ***instantiated in the context of*** non-generic call signature *B* as follows: +The subtype and assignment compatibility relationships require that source types have no excess properties with respect to their target types. The purpose of this check is to detect excess or misspelled properties in object literals. -* Using the process described in [3.10.6](#3.10.6), inferences for *A*'s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. +A source type *S* is considered to have excess properties with respect to a target type *T* if + +* *S* is a fresh object literal type, as defined below, and +* *S* has one or more properties that aren't expected in *T*. + +A property *P* is said to be expected in a type *T* if one of the following is true: + +* *T* is not an object, union, or intersection type. +* *T* is an object type and + * *T* has a property with the same name as *P*, + * *T* has a string or numeric index signature, + * *T* has no properties, or + * *T* is the global type 'Object'. +* *T* is a union or intersection type and *P* is expected in at least one of the constituent types of *T*. + +The type inferred for an object literal (as described in section [4.5](#4.5)) is considered a ***fresh object literal type***. The freshness disappears when an object literal type is widened ([3.12](#3.12)) or is the type of the expression in a type assertion ([4.16](#4.16)). + +Consider the following example: + +```TypeScript +interface CompilerOptions { + strict?: boolean; + sourcePath?: string; + targetPath?: string; +} + +var options: CompilerOptions = { + strict: true, + sourcepath: "./src", // Error, excess or misspelled property + targetpath: "./bin" // Error, excess or misspelled property +}; +``` + +The 'CompilerOptions' type contains only optional properties, so without the excess property check, *any* object literal would be assignable to the 'options' variable (because a misspelled property would just be considered an excess property of a different name). + +In cases where excess properties are expected, an index signature can be added to the target type as an indicator of intent: + +```TypeScript +interface InputElement { + name: string; + visible?: boolean; + [x: string]: any; // Allow additional properties of any type +} + +var address: InputElement = { + name: "Address", + visible: true, + help: "Enter address here", // Allowed because of index signature + shortcut: "Alt-A" // Allowed because of index signature +}; +``` + +### 3.11.6 Contextual Signature Instantiation + +During type argument inference in a function call (section [4.15.2](#4.15.2)) it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. A generic call signature *A* is ***instantiated in the context of*** non-generic call signature *B* as follows: + +* Using the process described in [3.11.7](#3.11.7), inferences for *A*'s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. * The inferred type argument for each type parameter is the union type of the set of inferences made for that type parameter. However, if the union type does not satisfy the constraint of the type parameter, the inferred type argument is instead the constraint. -### 3.10.6 Type Inference +### 3.11.7 Type Inference In certain contexts, inferences for a given set of type parameters are made *from* a type *S*, in which those type parameters do not occur, *to* another type *T*, in which those type parameters do occur. Inferences consist of a set of candidate type arguments collected for each of the type parameters. The inference process recursively relates *S* and *T* to gather as many inferences as possible: * If *T* is one of the type parameters for which inferences are being made, *S* is added to the set of inferences for that type parameter. * Otherwise, if *S* and *T* are references to the same generic type, inferences are made from each type argument in *S* to each corresponding type argument in *T*. -* Otherwise, if *T* is a union type: +* Otherwise, if *S* and *T* are tuple types with the same number of elements, inferences are made from each element type in *S* to each corresponding element type in *T*. +* Otherwise, if *T* is a union or intersection type: * First, inferences are made from *S* to each constituent type in *T* that isn't simply one of the type parameters for which inferences are being made. - * If the first step produced no inferences and exactly one constituent type in *T* is simply a type parameter for which inferences are being made, inferences are made from *S* to that type parameter. -* Otherwise, if *S* is a union type, inferences are made from each constituent type in *S* to *T*. + * If the first step produced no inferences then if T is a union type and exactly one constituent type in *T* is simply a type parameter for which inferences are being made, inferences are made from *S* to that type parameter. +* Otherwise, if *S* is a union or intersection type, inferences are made from each constituent type in *S* to *T*. * Otherwise, if *S* and *T* are object types, then for each member *M* in *T*: * If *M* is a property and *S* contains a property *N* with the same name as *M*, inferences are made from the type of *N* to the type of *M*. * If *M* is a call signature and a corresponding call signature *N* exists in *S*, *N* is instantiated with the Any type as an argument for each type parameter (if any) and inferences are made from parameter types in *N* to the corresponding parameter types in *M* for positions that are present in both signatures, and from the return type of *N* to the return type of *M*. @@ -2122,7 +2366,7 @@ In certain contexts, inferences for a given set of type parameters are made *fro When comparing call or construct signatures, signatures in *S* correspond to signatures of the same kind in *T* pairwise in declaration order. If *S* and *T* have different numbers of a given kind of signature, the excess *first* signatures in declaration order of the longer list are ignored. -### 3.10.7 Recursive Types +### 3.11.8 Recursive Types Classes and interfaces can reference themselves in their internal structure, in effect creating recursive types with infinite nesting. For example, the type @@ -2156,7 +2400,7 @@ interface List { 'List<T>' has a member 'owner' of type 'List<List<T>>', which has a member 'owner' of type 'List<List<List<T>>>', which has a member 'owner' of type 'List<List<List<List<T>>>>' and so on, ad infinitum. Since type relationships are determined structurally, possibly exploring the constituent types to their full depth, in order to determine type relationships involving infinitely expanding generic types it may be necessary for the compiler to terminate the recursion at some point with the assumption that no further exploration will change the outcome. -## 3.11 Widened Types +## 3.12 Widened Types In several situations TypeScript infers types from context, alleviating the need for the programmer to explicitly specify types that appear obvious. For example @@ -2171,7 +2415,7 @@ The following example shows the results of widening types to produce inferred va ```TypeScript var a = null; // var a: any var b = undefined; // var b: any -var c = { x: 0, y: null }; // var c: { x: number, y: any } +var c = { x: 0, y: null }; // var c: { x: number, y: any } var d = [ null, undefined ]; // var d: any[] ``` @@ -2185,17 +2429,15 @@ TypeScript's typing rules define a type for every expression construct. For exam In addition to type inference and type checking, TypeScript augments JavaScript expressions with the following constructs: -* Optional parameter and return type annotations in function expressions. -* Default parameter values and rest parameters in function expressions. -* Arrow function expressions. -* Super calls and member access. +* Optional parameter and return type annotations in function expressions and arrow functions. +* Type arguments in function calls. * Type assertions. Unless otherwise noted in the sections that follow, TypeScript expressions and the JavaScript expressions generated from them are identical. ## 4.1 Values and References -Expressions are classified as ***values*** or ***references***. References are the subset of expressions that are permitted as the target of an assignment. Specifically, references are combinations of identifiers (section [4.3](#4.3)), parentheses (section [4.7](#4.7)), and property accesses (section [4.10](#4.10)). All other expression constructs described in this chapter are classified as values. +Expressions are classified as ***values*** or ***references***. References are the subset of expressions that are permitted as the target of an assignment. Specifically, references are combinations of identifiers (section [4.3](#4.3)), parentheses (section [4.8](#4.8)), and property accesses (section [4.13](#4.13)). All other expression constructs described in this chapter are classified as values. ## 4.2 The this Keyword @@ -2203,18 +2445,18 @@ The type of `this` in an expression depends on the location in which the referen * In a constructor, instance member function, instance member accessor, or instance member variable initializer, `this` is of the class instance type of the containing class. * In a static member function or static member accessor, the type of `this` is the constructor function type of the containing class. -* In a function declaration or a standard function expression, `this` is of type Any. -* In the global module, `this` is of type Any. +* In a function declaration or a function expression, `this` is of type Any. +* In the global namespace, `this` is of type Any. In all other contexts it is a compile-time error to reference `this`. -In the body of an arrow function expression, references to `this` are rewritten in the generated JavaScript code, as described in section [4.9.2](#4.9.2). +Note that an arrow function (section [4.11](#4.11)) has no `this` parameter but rather preserves the `this` of its enclosing context. ## 4.3 Identifiers -When an expression is an *Identifier*, the expression refers to the most nested module, class, enum, function, variable, or parameter with that name whose scope (section [2.4](#2.4)) includes the location of the reference. The type of such an expression is the type associated with the referenced entity: +When an expression is an *IdentifierReference*, the expression refers to the most nested namespace, class, enum, function, variable, or parameter with that name whose scope (section [2.4](#2.4)) includes the location of the reference. The type of such an expression is the type associated with the referenced entity: -* For a module, the object type associated with the module instance. +* For a namespace, the object type associated with the namespace instance. * For a class, the constructor type associated with the constructor function object. * For an enum, the object type associated with the enum object. * For a function, the function type associated with the function object. @@ -2235,9 +2477,11 @@ Literals are typed as follows: ## 4.5 Object Literals -Object literals are extended to support type annotations in get and set accessors. +Object literals are extended to support type annotations in methods and get and set accessors. -  *PropertyAssignment:* *( Modified )* +  *PropertyDefinition:* *( Modified )* +   *IdentifierReference* +   *CoverInitializedName*    *PropertyName* `:` *AssignmentExpression*    *PropertyName* *CallSignature* `{` *FunctionBody* `}`    *GetAccessor* @@ -2247,17 +2491,29 @@ Object literals are extended to support type annotations in get and set accessor    `get` *PropertyName* `(` `)` *TypeAnnotationopt* `{` *FunctionBody* `}`   *SetAccessor:* -   `set` *PropertyName* `(` *Identifier* *TypeAnnotationopt* `)` `{` *FunctionBody* `}` +   `set` *PropertyName* `(` *BindingIdentifierOrPattern* *TypeAnnotationopt* `)` `{` *FunctionBody* `}` The type of an object literal is an object type with the set of properties specified by the property assignments in the object literal. A get and set accessor may specify the same property name, but otherwise it is an error to specify multiple property assignments for the same property. -A property assignment of the form +A shorthand property assignment of the form + +```TypeScript +prop +``` + +is equivalent to + +```TypeScript +prop : prop +``` + +Likewise, a property assignment of the form ```TypeScript f ( ... ) { ... } ``` -is simply shorthand for +is equivalent to ```TypeScript f : function ( ... ) { ... } @@ -2280,20 +2536,15 @@ A get accessor declaration is processed in the same manner as an ordinary functi If a get accessor is declared for a property, the return type of the get accessor becomes the type of the property. If only a set accessor is declared for a property, the parameter type (which may be type Any if no type annotation is present) of the set accessor becomes the type of the property. -When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section [3.8.4](#3.8.4)) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties. +When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section [3.9.4](#3.9.4)) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties. -## 4.6 Array Literals +If the *PropertyName* of a property assignment is a computed property name that doesn't denote a well-known symbol ([2.2.3](#2.2.3)), the construct is considered a ***dynamic property assignment***. The following rules apply to dynamic property assignments: -Array literals are extended to support the spread (`...`) operator. +* A dynamic property assignment does not introduce a property in the type of the object literal. +* The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. +* The name associated with a dynamic property assignment is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. -  *ElementList:* *( Modified )* -   *Elisionopt* *AssignmentExpression* -   *Elisionopt* *SpreadElement* -   *ElementList* `,` *Elisionopt* *AssignmentExpression* -   *ElementList* `,` *Elisionopt* *SpreadElement* - -  *SpreadElement:* -   `...` *AssignmentExpression* +## 4.6 Array Literals An array literal @@ -2305,7 +2556,7 @@ denotes a value of an array type (section [3.3.2](#3.3.2)) or a tuple type (sect Each element expression in a non-empty array literal is processed as follows: -* If the array literal contains no spread elements, and if the array literal is contextually typed (section [4.19](#4.19)) by a type *T* and *T* has a property with the numeric name *N*, where *N* is the index of the element expression in the array literal, the element expression is contextually typed by the type of that property. +* If the array literal contains no spread elements, and if the array literal is contextually typed (section [4.23](#4.23)) by a type *T* and *T* has a property with the numeric name *N*, where *N* is the index of the element expression in the array literal, the element expression is contextually typed by the type of that property. * Otherwise, if the array literal is contextually typed by a type *T* with a numeric index signature, the element expression is contextually typed by the type of the numeric index signature. * Otherwise, the element expression is not contextually typed. @@ -2313,11 +2564,13 @@ The resulting type an array literal expression is determined as follows: * If the array literal is empty, the resulting type is an array type with the element type Undefined. * Otherwise, if the array literal contains no spread elements and is contextually typed by a tuple-like type (section [3.3.3](#3.3.3)), the resulting type is a tuple type constructed from the types of the element expressions. -* Otherwise, if the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section [4.17.1](#4.17.1)), the resulting type is a tuple type constructed from the types of the element expressions. +* Otherwise, if the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section [4.21.1](#4.21.1)), the resulting type is a tuple type constructed from the types of the element expressions. * Otherwise, the resulting type is an array type with an element type that is the union of the types of the non-spread element expressions and the numeric index signature types of the spread element expressions. A spread element must specify an expression of an array-like type (section [3.3.2](#3.3.2)), or otherwise an error occurs. +*TODO: Document spreading an [iterator](https://github.com/Microsoft/TypeScript/pull/2498) into an array literal*. + The rules above mean that an array literal is always of an array type, unless it is contextually typed by a tuple-like type. For example ```TypeScript @@ -2340,7 +2593,11 @@ var a = [2, 3, 4]; var b = [0, 1].concat(a, [5, 6]); ``` -## 4.7 Parentheses +## 4.7 Template Literals + +*TODO: [Template literals](https://github.com/Microsoft/TypeScript/pull/960)*. + +## 4.8 Parentheses A parenthesized expression @@ -2350,72 +2607,78 @@ A parenthesized expression has the same type and classification as the contained expression itself. Specifically, if the contained expression is classified as a reference, so is the parenthesized expression. -## 4.8 The super Keyword +## 4.9 The super Keyword The `super` keyword can be used in expressions to reference base class properties and the base class constructor. -  *CallExpression:* *( Modified )* -   … -   `super` `(` *ArgumentListopt* `)` -   `super` `.` *IdentifierName* - -### 4.8.1 Super Calls +### 4.9.1 Super Calls Super calls consist of the keyword `super` followed by an argument list enclosed in parentheses. Super calls are only permitted in constructors of derived classes, as described in section [8.3.2](#8.3.2). -A super call invokes the constructor of the base class on the instance referenced by `this`. A super call is processed as a function call (section [4.12](#4.12)) using the construct signatures of the base class constructor function type as the initial set of candidate signatures for overload resolution. Type arguments cannot be explicitly specified in a super call. If the base class is a generic class, the type arguments used to process a super call are always those specified in the `extends` clause that references the base class. +A super call invokes the constructor of the base class on the instance referenced by `this`. A super call is processed as a function call (section [4.15](#4.15)) using the construct signatures of the base class constructor function type as the initial set of candidate signatures for overload resolution. Type arguments cannot be explicitly specified in a super call. If the base class is a generic class, the type arguments used to process a super call are always those specified in the `extends` clause that references the base class. The type of a super call expression is Void. The JavaScript code generated for a super call is specified in section [8.6.2](#8.6.2). -### 4.8.2 Super Property Access +### 4.9.2 Super Property Access A super property access consists of the keyword `super` followed by a dot and an identifier. Super property accesses are used to access base class member functions from derived classes and are permitted in contexts where `this` (section [4.2](#4.2)) references a derived class instance or a derived class constructor function. Specifically: * In a constructor, instance member function, instance member accessor, or instance member variable initializer where `this` references a derived class instance, a super property access is permitted and must specify a public instance member function of the base class. * In a static member function or static member accessor where `this` references the constructor function object of a derived class, a super property access is permitted and must specify a public static member function of the base class. -Super property accesses are not permitted in other contexts, and it is not possible to access other kinds of base class members in a super property access. Note that super property accesses are not permitted inside standard function expressions nested in the above constructs because `this` is of type Any in such function expressions. +Super property accesses are not permitted in other contexts, and it is not possible to access other kinds of base class members in a super property access. Note that super property accesses are not permitted inside function expressions nested in the above constructs because `this` is of type Any in such function expressions. Super property accesses are typically used to access overridden base class member functions from derived class member functions. For an example of this, see section [8.4.2](#8.4.2). The JavaScript code generated for a super property access is specified in section [8.6.2](#8.6.2). -## 4.9 Function Expressions +*TODO: Update section to include [bracket notation in super property access](https://github.com/Microsoft/TypeScript/issues/3970)*. -Function expressions are extended from JavaScript to optionally include parameter and return type annotations, and a new compact form, called arrow function expressions, is introduced. +## 4.10 Function Expressions + +Function expressions are extended from JavaScript to optionally include parameter and return type annotations.   *FunctionExpression:* *( Modified )* -   `function` *Identifieropt* *CallSignature* `{` *FunctionBody* `}` +   `function` *BindingIdentifieropt* *CallSignature* `{` *FunctionBody* `}` -  *AssignmentExpression:* *( Modified )* -   … -   *ArrowFunctionExpression* - -  *ArrowFunctionExpression:* -   *ArrowFormalParameters* `=>` *Block* -   *ArrowFormalParameters* `=>` *AssignmentExpression* - -  *ArrowFormalParameters:* -   *CallSignature* -   *Identifier* - -The terms ***standard function expression*** and ***arrow function expression*** are used to refer to the *FunctionExpression* and *ArrowFunctionExpression* forms respectively. When referring to either, the generic term ***function expression*** is used. +The descriptions of function declarations provided in chapter [6](#6) apply to function expressions as well, except that function expressions do not support overloading. The type of a function expression is an object type containing a single call signature with parameter and return types inferred from the function expression's signature and body. -The descriptions of function declarations provided in section [6.1](#6.1) apply to function expressions as well, except that function expressions do not support overloading. +When a function expression with no type parameters and no parameter type annotations is contextually typed (section [4.23](#4.23)) by a type *T* and a contextual signature *S* can be extracted from *T*, the function expression is processed as if it had explicitly specified parameter type annotations as they exist in *S*. Parameters are matched by position and need not have matching names. If the function expression has fewer parameters than *S*, the additional parameters in *S* are ignored. If the function expression has more parameters than *S*, the additional parameters are all considered to have type Any. -### 4.9.1 Standard Function Expressions +Likewise, when a function expression with no return type annotation is contextually typed (section [4.23](#4.23)) by a function type *T* and a contextual signature *S* can be extracted from *T*, expressions in contained return statements (section [5.10](#5.10)) are contextually typed by the return type of *S*. -Standard function expressions are function expressions written with the `function` keyword. The type of `this` in a standard function expression is the Any type. +A contextual signature *S* is extracted from a function type *T* as follows: -Standard function expressions are transformed to JavaScript in the same manner as function declarations (see section [6.6](#6.6)). +* If *T* is a function type with exactly one call signature, and if that call signature is non-generic, *S* is that signature. +* If *T* is a union type, let *U* be the set of element types in *T* that have call signatures. If each type in *U* has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, then *S* is a signature with the same parameters and a union of the return types. +* Otherwise, no contextual signature can be extracted from *T*. -### 4.9.2 Arrow Function Expressions +In the example -TypeScript supports ***arrow function expressions***, a new feature planned for ECMAScript 6. Arrow function expressions are a compact form of function expressions that omit the `function` keyword and have lexical scoping of `this`. +```TypeScript +var f: (s: string) => string = function (s) { + return s.toLowerCase(); +}; +``` + +the function expression is contextually typed by the type of 'f', and since the function expression has no type parameters or type annotations its parameter type information is extracted from the contextual type, thus inferring the type of 's' to be the String primitive type. + +## 4.11 Arrow Functions + +Arrow functions are extended from JavaScript to optionally include parameter and return type annotations. + +  *ArrowFormalParameters:* *( Modified )* +   *CallSignature* + +The descriptions of function declarations provided in chapter [6](#6) apply to arrow functions as well, except that arrow functions do not support overloading. + +The type of an arrow function is determined in the same manner as a function expression (section [4.10](#4.10)). Likewise, parameters of an arrow function and return statements in the body of an arrow function are contextually typed in the same manner as for function expressions. + +When an arrow function with an expression body and no return type annotation is contextually typed (section [4.23](#4.23)) by a function type *T* and a contextual signature *S* can be extracted from *T*, the expression body is contextually typed by the return type of *S*. An arrow function expression of the form @@ -2452,7 +2715,7 @@ x => { return Math.sin(x); } x => Math.sin(x) ``` -A function expression using the `function` keyword introduces a new dynamically bound `this`, whereas an arrow function expression preserves the `this` of its enclosing context. Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected `this`. +A function expression introduces a new dynamically bound `this`, whereas an arrow function expression preserves the `this` of its enclosing context. Arrow function expressions are particularly useful for writing callbacks, which otherwise often have an undefined or unexpected `this`. In the example @@ -2497,27 +2760,11 @@ could be parsed as an arrow function expression with a type parameter or a type < T > ( ( ... ) => { ... } ) ``` -### 4.9.3 Contextually Typed Function Expressions +## 4.12 Class Expressions -When a function expression with no type parameters and no parameter type annotations is contextually typed (section [4.19](#4.19)) by a type *T* and a contextual signature *S* can be extracted from *T*, the function expression is processed as if it had explicitly specified parameter type annotations as they exist in *S*. Parameters are matched by position and need not have matching names. If the function expression has fewer parameters than *S*, the additional parameters in *S* are ignored. If the function expression has more parameters than *S*, the additional parameters are all considered to have type Any. +*TODO: Document [class expressions](https://github.com/Microsoft/TypeScript/issues/497)*. -Likewise, when a function expression with no return type annotation is contextually typed (section [4.19](#4.19)) by a function type *T* and a contextual signature *S* can be extracted from *T*, expressions in contained return statements (section [5.7](#5.7)) are contextually typed by the return type of *S*. - -A contextual signature *S* is extracted from a function type *T* as follows: - -* If *T* is a function type with exactly one call signature, and if that call signature is non-generic, *S* is that signature. -* If *T* is a union type, let *U* be the set of element types in *T* that have call signatures. If each type in *U* has exactly one call signature and that call signature is non-generic, and if all of the signatures are identical ignoring return types, then *S* is a signature with the same parameters and a union of the return types. -* Otherwise, no contextual signature can be extracted from *T* and *S* is undefined. - -In the example - -```TypeScript -var f: (s: string) => string = s => s.toLowerCase(); -``` - -the function expression is contextually typed by the type of 'f', and since the function expression has no type parameters or type annotations its parameter type information is extracted from the contextual type, thus inferring the type of 's' to be the String primitive type. - -## 4.10 Property Access +## 4.13 Property Access A property access uses either dot notation or bracket notation. A property access expression is always classified as a reference. @@ -2530,7 +2777,7 @@ object . name where *object* is an expression and *name* is an identifier (including, possibly, a reserved word), is used to access the property with the given name on the given object. A dot notation property access is processed as follows at compile-time: * If *object* is of type Any, any *name* is permitted and the property access is of type Any. -* Otherwise, if *name* denotes an accessible apparent property (section [3.10.1](#3.10.1)) in the type of *object*, the property access is of the type of that property. Public members are always accessible, but private and protected members of a class have restricted accessibility, as described in [8.2.2](#8.2.2). +* Otherwise, if *name* denotes an accessible apparent property (section [3.11.1](#3.11.1)) in the type of *object*, the property access is of the type of that property. Public members are always accessible, but private and protected members of a class have restricted accessibility, as described in [8.2.2](#8.2.2). * Otherwise, the property access is invalid and a compile-time error occurs. A bracket notation property access of the form @@ -2541,12 +2788,14 @@ object [ index ] where *object* and *index* are expressions, is used to access the property with the name computed by the index expression on the given object. A bracket notation property access is processed as follows at compile-time: -* If *index* is a string literal or a numeric literal and *object* has an apparent property (section [3.10.1](#3.10.1)) with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. +* If *index* is a string literal or a numeric literal and *object* has an apparent property (section [3.11.1](#3.11.1)) with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. * Otherwise, if *object* has an apparent numeric index signature and *index* is of type Any, the Number primitive type, or an enum type, the property access is of the type of that index signature. * Otherwise, if *object* has an apparent string index signature and *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature. * Otherwise, if *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. * Otherwise, the property access is invalid and a compile-time error occurs. +*TODO: Indexing with [symbols](https://github.com/Microsoft/TypeScript/pull/1978)*. + The rules above mean that properties are strongly typed when accessed using bracket notation with the literal representation of their name. For example: ```TypeScript @@ -2567,7 +2816,7 @@ var s = data[0]; // string var n = data[1]; // number ``` -## 4.11 The new Operator +## 4.14 The new Operator A `new` operation has one of the following forms: @@ -2580,12 +2829,12 @@ new C < ... > ( ... ) where *C* is an expression. The first form is equivalent to supplying an empty argument list. *C* must be of type Any or of an object type with one or more construct or call signatures. The operation is processed as follows at compile-time: * If *C* is of type Any, any argument list is permitted and the result of the operation is of type Any. -* If *C* has one or more apparent construct signatures (section [3.10.1](#3.10.1)), the expression is processed in the same manner as a function call, but using the construct signatures as the initial set of candidate signatures for overload resolution. The result type of the function call becomes the result type of the operation. +* If *C* has one or more apparent construct signatures (section [3.11.1](#3.11.1)), the expression is processed in the same manner as a function call, but using the construct signatures as the initial set of candidate signatures for overload resolution. The result type of the function call becomes the result type of the operation. * If *C* has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. -## 4.12 Function Calls +## 4.15 Function Calls -Function calls are extended from JavaScript to optionally include type arguments. +Function calls are extended from JavaScript to support optional type arguments.   *Arguments:* *( Modified )*    *TypeArgumentsopt* `(` *ArgumentListopt* `)` @@ -2597,16 +2846,18 @@ func ( ... ) func < ... > ( ... ) ``` -where *func* is an expression of a function type or of type Any. The function expression is followed by an optional type argument list (section [3.5.2](#3.5.2)) and an argument list. +where *func* is an expression of a function type or of type Any. The function expression is followed by an optional type argument list (section [3.6.2](#3.6.2)) and an argument list. If *func* is of type Any, or of an object type that has no call or construct signatures but is a subtype of the Function interface, the call is an ***untyped function call***. In an untyped function call no type arguments are permitted, argument expressions can be of any type and number, no contextual types are provided for the argument expressions, and the result is always of type Any. -If *func* has apparent call signatures (section [3.10.1](#3.10.1)) the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. +If *func* has apparent call signatures (section [3.11.1](#3.11.1)) the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. -### 4.12.1 Overload Resolution +### 4.15.1 Overload Resolution The purpose of overload resolution in a function call is to ensure that at least one signature is applicable, to provide contextual types for the arguments, and to determine the result type of the function call, which could differ between the multiple applicable signatures. Overload resolution has no impact on the run-time behavior of a function call. Since JavaScript doesn't support function overloading, all that matters at run-time is the name of the function. +*TODO: Describe use of [wildcard function types](https://github.com/Microsoft/TypeScript/issues/3970) in overload resolution*. + The compile-time processing of a typed function call consists of the following steps: * First, a list of candidate signatures is constructed from the call signatures in the function type in declaration order. For classes and interfaces, inherited signatures are considered to follow explicitly declared signatures in `extends` clause order. @@ -2614,7 +2865,7 @@ The compile-time processing of a typed function call consists of the following s * the function call has no type arguments, and * the signature is applicable with respect to the argument list of the function call. * A generic signature is a candidate in a function call without type arguments when - * type inference (section [4.12.2](#4.12.2)) succeeds for each type parameter, + * type inference (section [4.15.2](#4.15.2)) succeeds for each type parameter, * once the inferred type arguments are substituted for their associated type parameters, the signature is applicable with respect to the argument list of the function call. * A generic signature is a candidate in a function call with type arguments when * The signature has the same number of type parameters as were supplied in the type argument list, @@ -2628,12 +2879,16 @@ A signature is said to be an ***applicable signature*** with respect to an argum * the number of arguments is not less than the number of required parameters, * the number of arguments is not greater than the number of parameters, and -* for each argument expression *e* and its corresponding parameter *P,* when *e* is contextually typed (section [4.19](#4.19)) by the type of *P*, no errors ensue and the type of *e* is assignable to (section [3.10.4](#3.10.4)) the type of *P*. +* for each argument expression *e* and its corresponding parameter *P,* when *e* is contextually typed (section [4.23](#4.23)) by the type of *P*, no errors ensue and the type of *e* is assignable to (section [3.11.4](#3.11.4)) the type of *P*. -### 4.12.2 Type Argument Inference +*TODO: [Spread operator in function calls](https://github.com/Microsoft/TypeScript/pull/1931) and spreading an [iterator](https://github.com/Microsoft/TypeScript/pull/2498) into a function call*. + +### 4.15.2 Type Argument Inference Given a signature < *T1* , *T2* , … , *Tn* > ( *p1* : *P1* , *p2* : *P2* , … , *pm* : *Pm* ), where each parameter type *P* references zero or more of the type parameters *T*, and an argument list ( *e1* , *e2* , … , *em* ), the task of type argument inference is to find a set of type arguments *A1*…*An* to substitute for *T1*…*Tn* such that the argument list becomes an applicable signature. +*TODO: Update [type argument inference and overload resolution rules](https://github.com/Microsoft/TypeScript/issues/1186)*. + Type argument inference produces a set of candidate types for each type parameter. Given a type parameter *T* and set of candidate types, the actual inferred type argument is determined as follows: * If the set of candidate argument types is empty, the inferred type argument for *T* is *T*'s constraint. @@ -2643,13 +2898,13 @@ Type argument inference produces a set of candidate types for each type paramete In order to compute candidate types, the argument list is processed as follows: * Initially all inferred type arguments are considered ***unfixed*** with an empty set of candidate types. -* Proceeding from left to right, each argument expression *e* is ***inferentially typed*** by its corresponding parameter type *P*, possibly causing some inferred type arguments to become ***fixed***, and candidate type inferences (section [3.10.6](#3.10.6)) are made for unfixed inferred type arguments from the type computed for *e* to *P*. +* Proceeding from left to right, each argument expression *e* is ***inferentially typed*** by its corresponding parameter type *P*, possibly causing some inferred type arguments to become ***fixed***, and candidate type inferences (section [3.11.7](#3.11.7)) are made for unfixed inferred type arguments from the type computed for *e* to *P*. The process of inferentially typing an expression *e* by a type *T* is the same as that of contextually typing *e* by *T*, with the following exceptions: * Where expressions contained within *e* would be contextually typed, they are instead inferentially typed. -* When a function expression is inferentially typed (section [4.9.3](#4.9.3)) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, the corresponding inferred type arguments to become ***fixed*** and no further candidate inferences are made for them. -* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are ***fixed***, and *e*'s type is changed to a function type with *e*'s call signature instantiated in the context of *T*'s call signature (section [3.10.5](#3.10.5)). +* When a function expression is inferentially typed (section [4.10](#4.10)) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, the corresponding inferred type arguments to become ***fixed*** and no further candidate inferences are made for them. +* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are ***fixed***, and *e*'s type is changed to a function type with *e*'s call signature instantiated in the context of *T*'s call signature (section [3.11.6](#3.11.6)). An example: @@ -2715,9 +2970,9 @@ var pairs = zip( and the resulting type of 'pairs' is therefore '{ name: string; age: number }[]'. -### 4.12.3 Grammar Ambiguities +### 4.15.3 Grammar Ambiguities -The inclusion of type arguments in the *Arguments* production (section [4.12](#4.12)) gives rise to certain ambiguities in the grammar for expressions. For example, the statement +The inclusion of type arguments in the *Arguments* production (section [4.15](#4.15)) gives rise to certain ambiguities in the grammar for expressions. For example, the statement ```TypeScript f(g(7)); @@ -2736,7 +2991,7 @@ f(g < A, B > +(7)); are both interpreted as calls to 'f' with two arguments. -## 4.13 Type Assertions +## 4.16 Type Assertions TypeScript extends the JavaScript expression grammar with the ability to assert a type for an expression: @@ -2746,7 +3001,7 @@ TypeScript extends the JavaScript expression grammar with the ability to assert A type assertion expression consists of a type enclosed in `<` and `>` followed by a unary expression. Type assertion expressions are purely a compile-time construct. Type assertions are *not* checked at run-time and have no impact on the emitted JavaScript (and therefore no run-time cost). The type and the enclosing `<` and `>` are simply removed from the generated code. -In a type assertion expression of the form < *T* > *e*, *e* is contextually typed (section [4.19](#4.19)) by *T* and the resulting type of* e* is required to be assignable to *T*, or *T* is required to be assignable to the widened form of the resulting type of *e*, or otherwise a compile-time error occurs. The type of the result is *T*. +In a type assertion expression of the form < *T* > *e*, *e* is contextually typed (section [4.23](#4.23)) by *T* and the resulting type of* e* is required to be assignable to *T*, or *T* is required to be assignable to the widened form of the resulting type of *e*, or otherwise a compile-time error occurs. The type of the result is *T*. Type assertions check for assignment compatibility in both directions. Thus, type assertions allow type conversions that *might* be correct, but aren't *known* to be correct. In the example @@ -2775,15 +3030,19 @@ if (shape instanceof Circle) { } ``` -## 4.14 Unary Operators +## 4.17 JSX Expressions + +*TODO: Document [JSX expressions](https://github.com/Microsoft/TypeScript/issues/3203)*. + +## 4.18 Unary Operators The subsections that follow specify the compile-time processing rules of the unary operators. In general, if the operand of a unary operator does not meet the stated requirements, a compile-time error occurs and the result of the operation defaults to type Any in further processing. -### 4.14.1 The ++ and -- operators +### 4.18.1 The ++ and -- operators These operators, in prefix or postfix form, require their operand to be of type Any, the Number primitive type, or an enum type, and classified as a reference (section [4.1](#4.1)). They produce a result of the Number primitive type. -### 4.14.2 The +, –, and ~ operators +### 4.18.2 The +, –, and ~ operators These operators permit their operand to be of any type and produce a result of the Number primitive type. @@ -2797,7 +3056,7 @@ var n = +getValue(); The example above converts the result of 'getValue()' to a number if it isn't a number already. The type inferred for 'n' is the Number primitive type regardless of the return type of 'getValue'. -### 4.14.3 The ! operator +### 4.18.3 The ! operator The ! operator permits its operand to be of any type and produces a result of the Boolean primitive type. @@ -2811,17 +3070,17 @@ var b = !!getValue(); The example above converts the result of 'getValue()' to a Boolean if it isn't a Boolean already. The type inferred for 'b' is the Boolean primitive type regardless of the return type of 'getValue'. -### 4.14.4 The delete Operator +### 4.18.4 The delete Operator The 'delete' operator takes an operand of any type and produces a result of the Boolean primitive type. -### 4.14.5 The void Operator +### 4.18.5 The void Operator -The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type ([3.2.6](#3.2.6)). +The 'void' operator takes an operand of any type and produces the value 'undefined'. The type of the result is the Undefined type ([3.2.7](#3.2.7)). -### 4.14.6 The typeof Operator +### 4.18.6 The typeof Operator -The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query (section [3.7.9](#3.7.9)) to produce the type of an expression. +The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query (section [3.8.10](#3.8.10)) to produce the type of an expression. ```TypeScript var x = 5; @@ -2831,11 +3090,11 @@ var z: typeof x; // Use in a type query In the example above, 'x' is of type 'number', 'y' is of type 'string' because when used in an expression, 'typeof' produces a value of type string (in this case the string "number"), and 'z' is of type 'number' because when used in a type query, 'typeof' obtains the type of an expression. -## 4.15 Binary Operators +## 4.19 Binary Operators The subsections that follow specify the compile-time processing rules of the binary operators. In general, if the operands of a binary operator do not meet the stated requirements, a compile-time error occurs and the result of the operation defaults to type any in further processing. Tables that summarize the compile-time processing rules for operands of the Any type, the Boolean, Number, and String primitive types, and all other types (the Other column in the tables) are provided. -### 4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators +### 4.19.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators These operators require their operands to be of type Any, the Number primitive type, or an enum type. Operands of an enum type are treated as having the primitive type Number. If one operand is the `null` or `undefined` value, it is treated as having the type of the other operand. The result is always of the Number primitive type. @@ -2847,7 +3106,7 @@ These operators require their operands to be of type Any, the Number primitive t |String|||||| |Other|||||| -### 4.15.2 The + operator +### 4.19.2 The + operator The binary + operator requires both operands to be of the Number primitive type or an enum type, or at least one of the operands to be of type Any or the String primitive type. Operands of an enum type are treated as having the primitive type Number. If one operand is the `null` or `undefined` value, it is treated as having the type of the other operand. If both operands are of the Number primitive type, the result is of the Number primitive type. If one or both operands are of the String primitive type, the result is of the String primitive type. Otherwise, the result is of type Any. @@ -2869,7 +3128,7 @@ var s = getValue() + ""; The example above converts the result of 'getValue()' to a string if it isn't a string already. The type inferred for 's' is the String primitive type regardless of the return type of 'getValue'. -### 4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators +### 4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators These operators require one or both of the operand types to be assignable to the other. The result is always of the Boolean primitive type. @@ -2881,17 +3140,17 @@ These operators require one or both of the operand types to be assignable to the |String|Boolean|||Boolean|| |Other|Boolean||||Boolean| -### 4.15.4 The instanceof operator +### 4.19.4 The instanceof operator The `instanceof` operator requires the left operand to be of type Any, an object type, or a type parameter type, and the right operand to be of type Any or a subtype of the 'Function' interface type. The result is always of the Boolean primitive type. Note that object types containing one or more call or construct signatures are automatically subtypes of the 'Function' interface type, as described in section [3.3](#3.3). -### 4.15.5 The in operator +### 4.19.5 The in operator The `in` operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, and the right operand to be of type Any, an object type, or a type parameter type. The result is always of the Boolean primitive type. -### 4.15.6 The && operator +### 4.19.6 The && operator The && operator permits the operands to be of any type and produces a result of the same type as the second operand. @@ -2903,11 +3162,11 @@ The && operator permits the operands to be of any type and produces a result of |String|Any|Boolean|Number|String|Other| |Other|Any|Boolean|Number|String|Other| -### 4.15.7 The || operator +### 4.19.7 The || operator The || operator permits the operands to be of any type. -If the || expression is contextually typed (section [4.19](#4.19)), the operands are contextually typed by the same type. Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. +If the || expression is contextually typed (section [4.23](#4.23)), the operands are contextually typed by the same type. Otherwise, the left operand is not contextually typed and the right operand is contextually typed by the type of the left operand. The type of the result is the union type of the two operand types. @@ -2919,7 +3178,7 @@ The type of the result is the union type of the two operand types. |String|Any|S | B|S | N|String|S | O| |Other|Any|B | O|N | O|S | O|Other| -## 4.16 The Conditional Operator +## 4.20 The Conditional Operator In a conditional expression of the form @@ -2929,11 +3188,11 @@ test ? expr1 : expr2 the *test* expression may be of any type. -If the conditional expression is contextually typed (section [4.19](#4.19)), *expr1* and *expr2* are contextually typed by the same type. Otherwise, *expr1* and *expr2* are not contextually typed. +If the conditional expression is contextually typed (section [4.23](#4.23)), *expr1* and *expr2* are contextually typed by the same type. Otherwise, *expr1* and *expr2* are not contextually typed. The type of the result is the union type of the types of *expr1* and *expr2*. -## 4.17 Assignment Operators +## 4.21 Assignment Operators An assignment of the form @@ -2941,7 +3200,7 @@ An assignment of the form v = expr ``` -requires *v* to be classified as a reference (section [4.1](#4.1)) or as an assignment pattern (section [4.17.1](#4.17.1)). The *expr* expression is contextually typed (section [4.19](#4.19)) by the type of *v*, and the type of *expr* must be assignable to (section [3.10.4](#3.10.4)) the type of *v*, or otherwise a compile-time error occurs. The result is a value with the type of *expr*. +requires *v* to be classified as a reference (section [4.1](#4.1)) or as an assignment pattern (section [4.21.1](#4.21.1)). The *expr* expression is contextually typed (section [4.23](#4.23)) by the type of *v*, and the type of *expr* must be assignable to (section [3.11.4](#3.11.4)) the type of *v*, or otherwise a compile-time error occurs. The result is a value with the type of *expr*. A compound assignment of the form @@ -2957,42 +3216,9 @@ where ??= is one of the compound assignment operators is subject to the same requirements, and produces a value of the same type, as the corresponding non-compound operation. A compound assignment furthermore requires *v* to be classified as a reference (section [4.1](#4.1)) and the type of the non-compound operation to be assignable to the type of *v*. Note that *v* is not permitted to be an assignment pattern in a compound assignment. -### 4.17.1 Destructuring Assignment +### 4.21.1 Destructuring Assignment -A ***destructuring assignment*** is an assignment operation in which the left hand operand is a destructuring assignment pattern. - -  *AssignmentPattern:* -   *ObjectAssignmentPattern* -   *ArrayAssignmentPattern* - -  *ObjectBindingPattern:* -   `{` `}` -   `{` *AssignmentPropertyList* `,`*opt* `}` - -  *AssignmentPropertyList:* -   *AssignmentProperty* -   *AssignmentPropertyList* `,` *AssignmentProperty* - -  *AssignmentProperty:* -   *Identifier* *Initialiseropt* -   *PropertyName* `:` *LeftHandSideExpression* *Initialiseropt* -   *PropertyName* `:` *AssignmentPattern* *Initialiseropt* - -  *ArrayAssignmentPattern:* -   `[` *Elisionopt* *AssignmentRestElementopt* `]` -   `[` *AssignmentElementList* `]` -   `[` *AssignmentElementList* `,` *Elisionopt* *AssignmentRestElementopt* `]` - -  *AssignmentElementList:* -   *Elisionopt* *AssignmentElement* -   *AssignmentElementList* `,` *Elisionopt* *AssignmentElement* - -  *AssignmentElement:* -   *LeftHandSideExpression* *Initialiseropt* -   *AssignmentPattern* *Initialiseropt* - -  *AssignmentRestElement:* -   `...` *LeftHandSideExpression* +A ***destructuring assignment*** is an assignment operation in which the left hand operand is a destructuring assignment pattern as defined by the *AssignmentPattern* production in the ECMAScript 6 specification. In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. An expression of type *S* is considered assignable to an assignment target *V* if one of the following is true: @@ -3009,9 +3235,7 @@ In a destructuring assignment expression, the type of the expression on the righ In an assignment property or element that includes a default value, the type of the default value must be assignable to the target given in the assignment property or element. -When the output target is ECMAScript 6 or higher, destructuring variable assignments remain unchanged in the emitted JavaScript code. - -When the output target is ECMAScript 3 or 5, destructuring variable assignments are rewritten to series of simple assignments. For example, the destructuring assignment +When the output target is ECMAScript 6 or higher, destructuring variable assignments remain unchanged in the emitted JavaScript code. When the output target is ECMAScript 3 or 5, destructuring variable assignments are rewritten to series of simple assignments. For example, the destructuring assignment ```TypeScript var x = 1; @@ -3028,18 +3252,18 @@ _a = [y, x], x = _a[0], y = _a[1]; var _a; ``` -## 4.18 The Comma Operator +## 4.22 The Comma Operator The comma operator permits the operands to be of any type and produces a result that is of the same type as the second operand. -## 4.19 Contextually Typed Expressions +## 4.23 Contextually Typed Expressions Type checking of an expression is improved in several contexts by factoring in the type of the destination of the value computed by the expression. In such situations, the expression is said to be ***contextually typed*** by the type of the destination. An expression is contextually typed in the following circumstances: * In a variable, parameter, binding property, binding element, or member declaration, an initializer expression is contextually typed by * the type given in the declaration's type annotation, if any, or otherwise - * for a parameter, the contextual type for the declaration (section [4.9.3](#4.9.3)), if any, or otherwise - * the type implied by the binding pattern in the declaration (section [5.1.3](#5.1.3)), if any. + * for a parameter, the type provided by a contextual signature (section [4.10](#4.10)), if any, or otherwise + * the type implied by the binding pattern in the declaration (section [5.2.3](#5.2.3)), if any. * In the body of a function declaration, function expression, arrow function, method declaration, or get accessor declaration that has a return type annotation, return expressions are contextually typed by the type given in the return type annotation. * In the body of a function expression or arrow function that has no return type annotation, if the function expression or arrow function is contextually typed by a function type with exactly one call signature, and if that call signature is non-generic, return expressions are contextually typed by the return type of that call signature. * In the body of a constructor declaration, return expressions are contextually typed by the containing class type. @@ -3083,7 +3307,7 @@ setEventHandlers({ the object literal passed to 'setEventHandlers' is contextually typed to the 'EventHandlers' type. This causes the two property assignments to be contextually typed to the unnamed function type '(event: EventObject) => void', which in turn causes the 'e' parameters in the arrow function expressions to automatically be typed as 'EventObject'. -## 4.20 Type Guards +## 4.24 Type Guards Type guards are particular expression patterns involving the 'typeof' and 'instanceof' operators that cause the types of variables or parameters to be ***narrowed*** to more specific types. For example, in the code below, knowledge of the static type of 'x' in combination with a 'typeof' check makes it safe to narrow the type of 'x' to string in the first branch of the 'if' statement and number in the second branch of the 'if' statement. @@ -3100,12 +3324,12 @@ function foo(x: number | string) { The type of a variable or parameter is narrowed in the following situations: -* In the true branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by a type guard in the 'if' condition *when true*, provided the true branch statement contains no assignments to the variable or parameter. -* In the false branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by a type guard in the 'if' condition *when false*, provided the false branch statement contains no assignments to the variable or parameter. -* In the true expression of a conditional expression, the type of a variable or parameter is *narrowed* by a type guard in the condition *when true*, provided the true expression contains no assignments to the variable or parameter. -* In the false expression of a conditional expression, the type of a variable or parameter is *narrowed* by a type guard in the condition *when false*, provided the false expression contains no assignments to the variable or parameter. -* In the right operand of a && operation, the type of a variable or parameter is *narrowed* by a type guard in the left operand *when true*, provided the right operand contains no assignments to the variable or parameter. -* In the right operand of a || operation, the type of a variable or parameter is *narrowed* by a type guard in the left operand *when false*, provided the right operand contains no assignments to the variable or parameter. +* In the true branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by a type guard in the 'if' condition *when true*, provided no part of the 'if' statement contains assignments to the variable or parameter. +* In the false branch statement of an 'if' statement, the type of a variable or parameter is *narrowed* by a type guard in the 'if' condition *when false*, provided no part of the 'if' statement contains assignments to the variable or parameter. +* In the true expression of a conditional expression, the type of a variable or parameter is *narrowed* by a type guard in the condition *when true*, provided no part of the conditional expression contains assignments to the variable or parameter. +* In the false expression of a conditional expression, the type of a variable or parameter is *narrowed* by a type guard in the condition *when false*, provided no part of the conditional expression contains assignments to the variable or parameter. +* In the right operand of a && operation, the type of a variable or parameter is *narrowed* by a type guard in the left operand *when true*, provided neither operand contains assignments to the variable or parameter. +* In the right operand of a || operation, the type of a variable or parameter is *narrowed* by a type guard in the left operand *when false*, provided neither operand contains assignments to the variable or parameter. A type guard is simply an expression that follows a particular pattern. The process of narrowing the type of a variable *x* by a type guard *when true* or *when false* depends on the type guard as follows: @@ -3198,17 +3422,29 @@ function getName(obj: Object) { } ``` -the type of `obj` is narrowed to `NamedItem` in the first condtional expression, and the inferred type of the `getName` function is `string`. +the type of `obj` is narrowed to `NamedItem` in the first conditional expression, and the inferred type of the `getName` function is `string`.
#
5 Statements -This chapter describes the static type checking TypeScript provides for JavaScript statements. TypeScript itself does not introduce any new statement constructs. +This chapter describes the static type checking TypeScript provides for JavaScript statements. TypeScript itself does not introduce any new statement constructs, but it does extend the grammar for local declarations to include interface, type alias, and enum declarations. -## 5.1 Variable Statements +## 5.1 Blocks -Variable statements are extended to include optional type annotations and ECMAScript 6 destructuring declarations. +Blocks are extended to include local interface, type alias, and enum declarations (classes are already included by the ECMAScript 6 grammar). + +  *Declaration:* *( Modified )* +   … +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* + +Local class, interface, type alias, and enum declarations are block scoped, similar to let and const declarations. + +## 5.2 Variable Statements + +Variable statements are extended to include optional type annotations.   *VariableDeclaration:* *( Modified )*    *SimpleVariableDeclaration* @@ -3216,23 +3452,20 @@ Variable statements are extended to include optional type annotations and ECMASc A variable declaration is either a simple variable declaration or a destructuring variable declaration. -### 5.1.1 Simple Variable Declarations +### 5.2.1 Simple Variable Declarations A ***simple variable declaration*** introduces a single named variable and optionally assigns it an initial value.   *SimpleVariableDeclaration:* -   *Identifier* *TypeAnnotationopt* *Initialiseropt* - -  *TypeAnnotation:* -   `:` *Type* +   *BindingIdentifier* *TypeAnnotationopt* *Initializeropt* The type *T* of a variable introduced by a simple variable declaration is determined as follows: * If the declaration includes a type annotation, *T* is that type. -* Otherwise, if the declaration includes an initializer expression, *T* is the widened form (section [3.11](#3.11)) of the type of the initializer expression. +* Otherwise, if the declaration includes an initializer expression, *T* is the widened form (section [3.12](#3.12)) of the type of the initializer expression. * Otherwise, *T* is the Any type. -When a variable declaration specifies both a type annotation and an initializer expression, the type of the initializer expression is required to be assignable to (section [3.10.4](#3.10.4)) the type given in the type annotation. +When a variable declaration specifies both a type annotation and an initializer expression, the type of the initializer expression is required to be assignable to (section [3.11.4](#3.11.4)) the type given in the type annotation. Multiple declarations for the same variable name in the same declaration space are permitted, provided that each declaration associates the same type with the variable. @@ -3270,47 +3503,16 @@ var d: { x: number; y: number; } = { x: 0, y: undefined }; var e = <{ x: number; y: number; }> { x: 0, y: undefined }; ``` -### 5.1.2 Destructuring Variable Declarations +### 5.2.2 Destructuring Variable Declarations A ***destructuring variable declaration*** introduces zero or more named variables and initializes them with values extracted from properties of an object or elements of an array.   *DestructuringVariableDeclaration:* -   *BindingPattern* *TypeAnnotationopt* *Initialiser* +   *BindingPattern* *TypeAnnotationopt* *Initializer* -  *BindingPattern:* -   *ObjectBindingPattern* -   *ArrayBindingPattern* +Each binding property or element that specifies an identifier introduces a variable by that name. The type of the variable is the widened form (section [3.12](#3.12)) of the type associated with the binding property or element, as defined in the following. -  *ObjectBindingPattern:* -   `{` `}` -   `{` *BindingPropertyList* `,`*opt* `}` - -  *BindingPropertyList:* -   *BindingProperty* -   *BindingPropertyList* `,` *BindingProperty* - -  *BindingProperty:* -   *Identifier* *Initialiseropt* -   *PropertyName* `:` *Identifier* *Initialiseropt* -   *PropertyName* `:` *BindingPattern* *Initialiseropt* - -  *ArrayBindingPattern:* -   `[` *Elisionopt* *BindingRestElementopt* `]` -   `[` *BindingElementList* `]` -   `[` *BindingElementList* `,` *Elisionopt* *BindingRestElementopt* `]` - -  *BindingElementList:* -   *Elisionopt* *BindingElement* -   *BindingElementList* `,` *Elisionopt* *BindingElement* - -  *BindingElement:* -   *Identifier* *Initialiseropt* -   *BindingPattern* *Initialiseropt* - -  *BindingRestElement:* -   `...` *Identifier* - -Each binding property or element that specifies an identifier introduces a variable by that name. The type of the variable is the widened form (section [3.11](#3.11)) of the type associated with the binding property or element, as defined in the following. +*TODO: Document destructuring an [iterator](https://github.com/Microsoft/TypeScript/pull/2498) into an array*. The type *T* associated with a destructuring variable declaration is determined as follows: @@ -3401,7 +3603,7 @@ var _a = getSomeObject(), z = _d === void 0 ? 10 : _d; ``` -### 5.1.3 Implied Type +### 5.2.3 Implied Type A variable, parameter, binding property, or binding element declaration that specifies a binding pattern has an ***implied type*** which is determined as follows: @@ -3431,15 +3633,31 @@ var [a, b, c] = [1, "hello", true]; the array literal initializer expression is contextually typed by the implied type of the binding pattern, specifically the tuple type '[any, any, any]'. Because the contextual type is a tuple type, the resulting type of the array literal is the tuple type '[number, string, boolean]', and the destructuring declaration thus gives the types number, string, and boolean to a, b, and c respectively. -## 5.2 If, Do, and While Statements +## 5.3 Let and Const Declarations + +Let and const declarations are exended to include optional type annotations. + +  *LexicalBinding:* *( Modified )* +   *SimpleLexicalBinding* +   *DestructuringLexicalBinding* + +  *SimpleLexicalBinding:* +   *BindingIdentifier* *TypeAnnotationopt* *Initializeropt* + +  *DestructuringLexicalBinding:* +   *BindingPattern* *TypeAnnotationopt* *Initializeropt* + +*TODO: Document scoping and types of [let and const declarations](https://github.com/Microsoft/TypeScript/pull/904)*. + +## 5.4 If, Do, and While Statements Expressions controlling 'if', 'do', and 'while' statements can be of any type (and not just type Boolean). -## 5.3 For Statements +## 5.5 For Statements -Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements (section [5.1](#5.1)). +Variable declarations in 'for' statements are extended in the same manner as variable declarations in variable statements (section [5.2](#5.2)). -## 5.4 For-In Statements +## 5.6 For-In Statements In a 'for-in' statement of the form @@ -3457,21 +3675,25 @@ for (var v in expr) statement *v* must be a variable declaration without a type annotation that declares a variable of type Any, and *expr* must be an expression of type Any, an object type, or a type parameter type. -## 5.5 Continue Statements +## 5.7 For-Of Statements + +*TODO: Document [for-of statements](https://github.com/Microsoft/TypeScript/issues/7)*. + +## 5.8 Continue Statements A 'continue' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') statement. When a 'continue' statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) iteration statement. -## 5.6 Break Statements +## 5.9 Break Statements A 'break' statement is required to be nested, directly or indirectly (but not crossing function boundaries), within an iteration ('do', 'while', 'for', or 'for-in') or 'switch' statement. When a 'break' statement includes a target label, that target label must appear in the label set of an enclosing (but not crossing function boundaries) statement. -## 5.7 Return Statements +## 5.10 Return Statements -It is an error for a 'return' statement to occur outside a function body. Specifically, 'return' statements are not permitted at the global level or in module bodies. +It is an error for a 'return' statement to occur outside a function body. Specifically, 'return' statements are not permitted at the global level or in namespace bodies. A 'return' statement without an expression returns the value 'undefined' and is permitted in the body of any function, regardless of the return type of the function. -When a 'return' statement includes an expression, if the containing function includes a return type annotation, the return expression is contextually typed (section [4.19](#4.19)) by that return type and must be of a type that is assignable to the return type. Otherwise, if the containing function is contextually typed by a type *T*, *Expr* is contextually typed by *T*'s return type. +When a 'return' statement includes an expression, if the containing function includes a return type annotation, the return expression is contextually typed (section [4.23](#4.23)) by that return type and must be of a type that is assignable to the return type. Otherwise, if the containing function is contextually typed by a type *T*, *Expr* is contextually typed by *T*'s return type. In a function implementation without a return type annotation, the return type is inferred from the 'return' statements in the function body, as described in section [6.3](#6.3). @@ -3485,19 +3707,19 @@ function f(): (x: string) => number { the arrow expression in the 'return' statement is contextually typed by the return type of 'f', thus giving type 'string' to 's'. -## 5.8 With Statements +## 5.11 With Statements Use of the 'with' statement in TypeScript is an error, as is the case in ECMAScript 5's strict mode. Furthermore, within the body of a 'with' statement, TypeScript considers every identifier occurring in an expression (section [4.3](#4.3)) to be of the Any type regardless of its declared type. Because the 'with' statement puts a statically unknown set of identifiers in scope in front of those that are statically known, it is not possible to meaningfully assign a static type to any identifier. -## 5.9 Switch Statements +## 5.12 Switch Statements -In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section [3.10.4](#3.10.4)) the type of the 'switch' expression. +In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section [3.11.4](#3.11.4)) the type of the 'switch' expression. -## 5.10 Throw Statements +## 5.13 Throw Statements The expression specified in a 'throw' statement can be of any type. -## 5.11 Try Statements +## 5.14 Try Statements The variable introduced by a 'catch' clause of a 'try' statement is always of type Any. It is not possible to include a type annotation in a 'catch' clause. @@ -3509,26 +3731,23 @@ TypeScript extends JavaScript functions to include type parameters, parameter an ## 6.1 Function Declarations -Function declarations consist of an optional set of function overloads followed by an actual function implementation. +Function declarations are extended to permit the function body to be omitted in overload declarations.   *FunctionDeclaration:* *( Modified )* -   *FunctionOverloadsopt* *FunctionImplementation* +   `function` *BindingIdentifieropt* *CallSignature* `{` *FunctionBody* `}` +   `function` *BindingIdentifieropt* *CallSignature* `;` -  *FunctionOverloads:* -   *FunctionOverload* -   *FunctionOverloads* *FunctionOverload* +A *FunctionDeclaration* introduces a named value of a function type in the containing declaration space. The *BindingIdentifier* is optional only when the function declaration occurs in an export default declaration (section [11.3.4.2](#11.3.4.2)). -  *FunctionOverload:* -   `function` *Identifier* *CallSignature* `;` +Function declarations that specify a body are called ***function implementations*** and function declarations without a body are called ***function overloads***. It is possible to specify multiple overloads for the same function (i.e. for the same name in the same declaration space), but a function can have at most one implementation. All declarations for the same function must specify the same set of modifiers (i.e. the same combination of `declare`, `export`, and `default`). -  *FunctionImplementation:* -   `function` *Identifier* *CallSignature* `{` *FunctionBody* `}` +When a function has overload declarations, the overloads determine the call signatures of the type given to the function object and the function implementation signature (if any) must be assignable to that type. Otherwise, the function implementation itself determines the call signature. -A function declaration introduces a function with the given name in the containing declaration space. Function overloads, if present, must specify the same name as the function implementation. If a function declaration includes overloads, the overloads determine the call signatures of the type given to the function object and the function implementation signature must be assignable to that type. Otherwise, the function implementation itself determines the call signature. Function overloads have no other effect on a function declaration. +When a function has both overloads and an implementation, the overloads must precede the implementation and all of the declarations must be consecutive with no intervening grammatical elements. ## 6.2 Function Overloads -Function overloads allow a more accurate specification of the patterns of invocation supported by a function than is possible with a single signature. The compile-time processing of a call to an overloaded function chooses the best candidate overload for the particular arguments and the return type of that overload becomes the result type the function call expression. Thus, using overloads it is possible to statically describe the manner in which a function's return type varies based on its arguments. Overload resolution in function calls is described further in section [4.12](#4.12). +Function overloads allow a more accurate specification of the patterns of invocation supported by a function than is possible with a single signature. The compile-time processing of a call to an overloaded function chooses the best candidate overload for the particular arguments and the return type of that overload becomes the result type the function call expression. Thus, using overloads it is possible to statically describe the manner in which a function's return type varies based on its arguments. Overload resolution in function calls is described further in section [4.15](#4.15). Function overloads are purely a compile-time construct. They have no impact on the emitted JavaScript and thus no run-time cost. @@ -3568,8 +3787,8 @@ A function implementation without a return type annotation is said to be an ***i * If there are no return statements with expressions in *f*'s function body, the inferred return type is Void. * Otherwise, if *f*'s function body directly references *f* or references any implicitly typed functions that through this same analysis reference *f*, the inferred return type is Any. -* Otherwise, if *f* is a contextually typed function expression (section [4.9.3](#4.9.3)), the inferred return type is the union type (section [3.4](#3.4)) of the types of the return statement expressions in the function body, ignoring return statements with no expressions. -* Otherwise, the inferred return type is the first of the types of the return statement expressions in the function body that is a supertype (section [3.10.3](#3.10.3)) of each of the others, ignoring return statements with no expressions. A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. +* Otherwise, if *f* is a contextually typed function expression (section [4.10](#4.10)), the inferred return type is the union type (section [3.4](#3.4)) of the types of the return statement expressions in the function body, ignoring return statements with no expressions. +* Otherwise, the inferred return type is the first of the types of the return statement expressions in the function body that is a supertype (section [3.11.3](#3.11.3)) of each of the others, ignoring return statements with no expressions. A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. In the example @@ -3590,11 +3809,11 @@ An explicitly typed function whose return type isn't the Void or the Any type mu The type of 'this' in a function implementation is the Any type. -In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. When a parameter declaration has no type annotation but includes an initializer, the type of the parameter is the widened form (section [3.11](#3.11)) of the type of the initializer expression. +In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed (section [4.23](#4.23)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. When a parameter declaration has no type annotation but includes an initializer, the type of the parameter is the widened form (section [3.12](#3.12)) of the type of the initializer expression. Initializer expressions are evaluated in the scope of the function body but are not permitted to reference local variables and are only permitted to access parameters that are declared to the left of the parameter they initialize, unless the parameter reference occurs in a nested function expression. -For each parameter with an initializer, a statement that substitutes the default value for an omitted argument is included in the generated JavaScript, as described in section [6.6](#6.6). The example +When the output target is ECMAScript 3 or 5, for each parameter with an initializer, a statement that substitutes the default value for an omitted argument is included in the generated JavaScript, as described in section [6.6](#6.6). The example ```TypeScript function strange(x: number, y = x * 2, z = x + y) { @@ -3625,13 +3844,14 @@ the local variable 'x' is in scope in the parameter initializer (thus hiding the ## 6.4 Destructuring Parameter Declarations -Parameter declarations can specify binding patterns (section [3.8.2.2](#3.8.2.2)) and are then called ***destructuring parameter declarations***. Similar to a destructuring variable declaration (section [5.1.2](#5.1.2)), a destructuring parameter declaration introduces zero or more named locals and initializes them with values extracted from properties or elements of the object or array passed as an argument for the parameter. +Parameter declarations can specify binding patterns (section [3.9.2.2](#3.9.2.2)) and are then called ***destructuring parameter declarations***. Similar to a destructuring variable declaration (section [5.2.2](#5.2.2)), a destructuring parameter declaration introduces zero or more named locals and initializes them with values extracted from properties or elements of the object or array passed as an argument for the parameter. The type of local introduced in a destructuring parameter declaration is determined in the same manner as a local introduced by a destructuring variable declaration, except the type *T* associated with a destructuring parameter declaration is determined as follows: * If the declaration includes a type annotation, *T* is that type. -* Otherwise, if the declaration includes an initializer expression, *T* is the widened form (section [3.11](#3.11)) of the type of the initializer expression. -* Otherwise, if the declaration specifies a binding pattern, *T* is the implied type of that binding pattern (section [5.1.3](#5.1.3)). +* If the declaration occurs in a function expression for which a contextual signature is available (section [4.10](#4.10)), *T* is the type obtained from the contextual signature. +* Otherwise, if the declaration includes an initializer expression, *T* is the widened form (section [3.12](#3.12)) of the type of the initializer expression. +* Otherwise, if the declaration specifies a binding pattern, *T* is the implied type of that binding pattern (section [5.2.3](#5.2.3)). * Otherwise, if the parameter is a rest parameter, *T* is `any[]`. * Otherwise, *T* is `any`. @@ -3683,7 +3903,7 @@ function drawText({ text, location: [x, y], bold }: DrawTextInfo) { ## 6.5 Generic Functions -A function implementation may include type parameters in its signature (section [3.8.2.1](#3.8.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. +A function implementation may include type parameters in its signature (section [3.9.2.1](#3.9.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. Type parameters declared in the signature of a function implementation are in scope in the signature and body of that function implementation. @@ -3701,9 +3921,9 @@ function compare(x: T, y: T): number { } ``` -Note that the 'x' and 'y' parameters are known to be subtypes of the constraint 'Comparable' and therefore have a 'compareTo' member. This is described further in section [3.5.1](#3.5.1). +Note that the 'x' and 'y' parameters are known to be subtypes of the constraint 'Comparable' and therefore have a 'compareTo' member. This is described further in section [3.6.1](#3.6.1). -The type arguments of a call to a generic function may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. In the example +The type arguments of a call to a generic function may be explicitly specified in a call operation or may, when possible, be inferred (section [4.15.2](#4.15.2)) from the types of the regular arguments in the call. In the example ```TypeScript class Person { @@ -3741,6 +3961,14 @@ where *Parameter* is the parameter name and *Default* is the default value expre *FunctionStatements* is the code generated for the statements specified in the function body. +## 6.7 Generator Functions + +*TODO: Document [generator functions](https://github.com/Microsoft/TypeScript/issues/2873)*. + +## 6.8 Type Guard Functions + +*TODO: Document [type guard functions](https://github.com/Microsoft/TypeScript/issues/1007)*. +
#
7 Interfaces @@ -3749,16 +3977,16 @@ Interfaces provide the ability to name and parameterize object types and to comp Interfaces have no run-time representation—they are purely a compile-time construct. Interfaces are particularly useful for documenting and validating the required shape of properties, objects passed as parameters, and objects returned from functions. -Because TypeScript has a structural type system, an interface type with a particular set of members is considered identical to, and can be substituted for, another interface type or object type literal with an identical set of members (see section [3.10.2](#3.10.2)). +Because TypeScript has a structural type system, an interface type with a particular set of members is considered identical to, and can be substituted for, another interface type or object type literal with an identical set of members (see section [3.11.2](#3.11.2)). Class declarations may reference interfaces in their implements clause to validate that they provide an implementation of the interfaces. ## 7.1 Interface Declarations -An interface declaration declares a new named type (section [3.6](#3.6)) by introducing a type name in the containing module. +An interface declaration declares an ***interface type***.   *InterfaceDeclaration:* -   `interface` *Identifier* *TypeParametersopt* *InterfaceExtendsClauseopt* *ObjectType* +   `interface` *BindingIdentifier* *TypeParametersopt* *InterfaceExtendsClauseopt* *ObjectType*   *InterfaceExtendsClause:*    `extends` *ClassOrInterfaceTypeList* @@ -3770,9 +3998,9 @@ An interface declaration declares a new named type (section [3.6](#3.6)) by intr   *ClassOrInterfaceType:*    *TypeReference* -The *Identifier* of an interface declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). +An *InterfaceDeclaration* introduces a named type (section [3.7](#3.7)) in the containing declaration space. The *BindingIdentifier* of an interface declaration may not be one of the predefined type names (section [3.8.1](#3.8.1)). -An interface may optionally have type parameters (section [3.5.1](#3.5.1)) that serve as placeholders for actual types to be provided when the interface is referenced in type references. An interface with type parameters is called a ***generic interface***. The type parameters of a generic interface declaration are in scope in the entire declaration and may be referenced in the *InterfaceExtendsClause* and *ObjectType* body. +An interface may optionally have type parameters (section [3.6.1](#3.6.1)) that serve as placeholders for actual types to be provided when the interface is referenced in type references. An interface with type parameters is called a ***generic interface***. The type parameters of a generic interface declaration are in scope in the entire declaration and may be referenced in the *InterfaceExtendsClause* and *ObjectType* body. An interface can inherit from zero or more ***base types*** which are specified in the *InterfaceExtendsClause*. The base types must be type references to class or interface types. @@ -3786,9 +4014,9 @@ The following constraints must be satisfied by an interface declaration or other * An interface declaration may not, directly or indirectly, specify a base type that originates in the same declaration. In other words an interface cannot, directly or indirectly, be a base type of itself, regardless of type arguments. * An interface cannot declare a property with the same name as an inherited private or protected property. -* Inherited properties with the same name must be identical (section [3.10.2](#3.10.2)). -* All properties of the interface must satisfy the constraints implied by the index signatures of the interface as specified in section [3.8.4](#3.8.4). -* The instance type (section [3.6.1](#3.6.1)) of the declared interface must be assignable (section [3.10.4](#3.10.4)) to each of the base type references. +* Inherited properties with the same name must be identical (section [3.11.2](#3.11.2)). +* All properties of the interface must satisfy the constraints implied by the index signatures of the interface as specified in section [3.9.4](#3.9.4). +* The instance type (section [3.7.1](#3.7.1)) of the declared interface must be assignable (section [3.11.4](#3.11.4)) to each of the base type references. An interface is permitted to inherit identical members from multiple base types and will in that case only contain one occurrence of each particular member. @@ -3891,7 +4119,7 @@ class Location { } ``` -In the above example, 'SelectableControl' contains all of the members of 'Control', including the private 'state' property. Since 'state' is a private member it is only possible for descendants of 'Control' to implement 'SelectableControl'. This is because only descendants of 'Control' will have a 'state' private member that originates in the same declaration, which is a requirement for private members to be compatible (section [3.10](#3.10)). +In the above example, 'SelectableControl' contains all of the members of 'Control', including the private 'state' property. Since 'state' is a private member it is only possible for descendants of 'Control' to implement 'SelectableControl'. This is because only descendants of 'Control' will have a 'state' private member that originates in the same declaration, which is a requirement for private members to be compatible (section [3.11](#3.11)). Within the 'Control' class it is possible to access the 'state' private member through an instance of 'SelectableControl'. Effectively, a 'SelectableControl' acts like a 'Control' that is known to have a 'select' method. The 'Button' and 'TextBox' classes are subtypes of 'SelectableControl' (because they both inherit from 'Control' and have a 'select' method), but the 'Image' and 'Location' classes are not. @@ -3919,24 +4147,24 @@ function asMoverShaker(obj: any): MoverShaker { # 8 Classes -TypeScript supports classes that are closely aligned with those proposed for ECMAScript 6, and includes extensions for instance and static member declarations and properties declared and initialized from constructor parameters. +TypeScript extends JavaScript classes to include type parameters, implements clauses, accessibility modifiers, member variable declarations, and parameter property declarations in constructors. -*NOTE: TypeScript currently doesn't support class expressions or nested class declarations from the ECMAScript 6 proposal*. +*TODO: Document [abstract classes](https://github.com/Microsoft/TypeScript/issues/3578)*. ## 8.1 Class Declarations -Class declarations introduce named types and provide implementations of those types. Classes support inheritance, allowing derived classes to extend and specialize base classes. +A class declaration declares a ***class type*** and a ***constructor function***. -  *ClassDeclaration:* -   `class` *Identifier* *TypeParametersopt* *ClassHeritage* `{` *ClassBody* `}` +  *ClassDeclaration:* *( Modified )* +   `class` *BindingIdentifieropt* *TypeParametersopt* *ClassHeritage* `{` *ClassBody* `}` -A *ClassDeclaration* declares a ***class type*** and a ***constructor function***, both with the name given by *Identifier*, in the containing module. The class type is created from the instance members declared in the class body and the instance members inherited from the base class. The constructor function is created from the constructor declaration, the static member declarations in the class body, and the static members inherited from the base class. The constructor function initializes and returns an instance of the class type. +A *ClassDeclaration* introduces a named type (the class type) and a named value (the constructor function) in the containing declaration space. The class type is formed from the instance members declared in the class body and the instance members inherited from the base class. The constructor function is given an anonymous type formed from the constructor declaration, the static member declarations in the class body, and the static members inherited from the base class. The constructor function initializes and returns an instance of the class type. -The *Identifier* of a class declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). +The *BindingIdentifier* of a class declaration may not be one of the predefined type names (section [3.8.1](#3.8.1)). The *BindingIdentifier* is optional only when the class declaration occurs in an export default declaration (section [11.3.4.2](#11.3.4.2)). -A class may optionally have type parameters (section [3.5.1](#3.5.1)) that serve as placeholders for actual types to be provided when the class is referenced in type references. A class with type parameters is called a ***generic class***. The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the *ClassHeritage* and *ClassBody*. +A class may optionally have type parameters (section [3.6.1](#3.6.1)) that serve as placeholders for actual types to be provided when the class is referenced in type references. A class with type parameters is called a ***generic class***. The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the *ClassHeritage* and *ClassBody*. -The following example introduces both a named type called 'Point' (the class type) and a member called 'Point' (the constructor function) in the containing module. +The following example introduces both a named type called 'Point' (the class type) and a named value called 'Point' (the constructor function) in the containing declaration space. ```TypeScript class Point { @@ -3946,7 +4174,7 @@ class Point { } ``` -The 'Point' type is exactly equivalent to +The named type 'Point' is exactly equivalent to ```TypeScript interface Point { @@ -3956,7 +4184,7 @@ interface Point { } ``` -The 'Point' member is a constructor function whose type corresponds to the declaration +The named value 'Point' is a constructor function whose type corresponds to the declaration ```TypeScript var Point: { @@ -3975,9 +4203,11 @@ the identifier 'Point' in the type annotation refers to the class instance type, ### 8.1.1 Class Heritage Specification +*TODO: Update this section to reflect [expressions in class extends clauses](https://github.com/Microsoft/TypeScript/pull/3516)*. + The heritage specification of a class consists of optional `extends` and `implements` clauses. The `extends` clause specifies the base class of the class and the `implements` clause specifies a set of interfaces for which to validate the class provides an implementation. -  *ClassHeritage:* +  *ClassHeritage:* *( Modified )*    *ClassExtendsClauseopt* *ImplementsClauseopt*   *ClassExtendsClause:* @@ -3995,7 +4225,7 @@ The following constraints must be satisfied by the class heritage specification * If present, the type reference specified in the `extends` clause must denote a class type. Furthermore, the *TypeName* part of the type reference is required to be a reference to the class constructor function when evaluated as an expression. * A class declaration may not, directly or indirectly, specify a base class that originates in the same declaration. In other words a class cannot, directly or indirectly, be a base class of itself, regardless of type arguments. -* The instance type (section [3.6.1](#3.6.1)) of the declared class must be assignable (section [3.10.4](#3.10.4)) to the base type reference and each of the type references listed in the `implements` clause. +* The instance type (section [3.7.1](#3.7.1)) of the declared class must be assignable (section [3.11.4](#3.11.4)) to the base type reference and each of the type references listed in the `implements` clause. * The constructor function type created by the class declaration must be assignable to the base class constructor function type, ignoring construct signatures. The following example illustrates a situation in which the first rule above would be violated: @@ -4003,7 +4233,7 @@ The following example illustrates a situation in which the first rule above woul ```TypeScript class A { a: number; } -module Foo { +namespace Foo { var A = 1; class B extends A { b: string; } } @@ -4019,14 +4249,7 @@ Note that because TypeScript has a structural type system, a class doesn't need The class body consists of zero or more constructor or member declarations. Statements are not allowed in the body of a class—they must be placed in the constructor or in members. -  *ClassBody:* -   *ClassElementsopt* - -  *ClassElements:* -   *ClassElement* -   *ClassElements* *ClassElement* - -  *ClassElement:* +  *ClassElement:* *( Modified )*    *ConstructorDeclaration*    *PropertyMemberDeclaration*    *IndexMemberDeclaration* @@ -4043,7 +4266,7 @@ The members of a class consist of the members introduced through member declarat Members are either ***instance members*** or ***static members***. -Instance members are members of the class type (section [8.2.4](#8.2.4)) and its associated instance type. Within constructors, instance member functions, and instance member accessors, the type of `this` is the instance type (section [3.6.1](#3.6.1)) of the class. +Instance members are members of the class type (section [8.2.4](#8.2.4)) and its associated instance type. Within constructors, instance member functions, and instance member accessors, the type of `this` is the instance type (section [3.7.1](#3.7.1)) of the class. Static members are declared using the `static` modifier and are members of the constructor function type (section [8.2.5](#8.2.5)). Within static member functions and static member accessors, the type of `this` is the constructor function type. @@ -4091,7 +4314,7 @@ In class 'A', the accesses to 'x' are permitted because 'x' is declared in 'A', A derived class ***inherits*** all members from its base class it doesn't ***override***. Inheritance means that a derived class implicitly contains all non-overridden members of the base class. Only public and protected property members can be overridden. -A property member in a derived class is said to override a property member in a base class when the derived class property member has the same name and kind (instance or static) as the base class property member. The type of an overriding property member must be assignable (section [3.10.4](#3.10.4)) to the type of the overridden property member, or otherwise a compile-time error occurs. +A property member in a derived class is said to override a property member in a base class when the derived class property member has the same name and kind (instance or static) as the base class property member. The type of an overriding property member must be assignable (section [3.11.4](#3.11.4)) to the type of the overridden property member, or otherwise a compile-time error occurs. Base class instance member functions can be overridden by derived class instance member functions, but not by other kinds of members. @@ -4099,11 +4322,11 @@ Base class instance member variables and accessors can be overridden by derived Base class static property members can be overridden by derived class static property members of any kind as long as the types are compatible, as described above. -An index member in a derived class is said to override an index member in a base class when the derived class index member is of the same index kind (string or numeric) as the base class index member. The type of an overriding index member must be assignable (section [3.10.4](#3.10.4)) to the type of the overridden index member, or otherwise a compile-time error occurs. +An index member in a derived class is said to override an index member in a base class when the derived class index member is of the same index kind (string or numeric) as the base class index member. The type of an overriding index member must be assignable (section [3.11.4](#3.11.4)) to the type of the overridden index member, or otherwise a compile-time error occurs. ### 8.2.4 Class Types -A class declaration declares a new named type (section [3.6](#3.6)) called a class type. Within the constructor and member functions of a class, the type of `this` is the instance type (section [3.6.1](#3.6.1)) of this class type. The class type has the following members: +A class declaration declares a new named type (section [3.7](#3.7)) called a class type. Within the constructor and member functions of a class, the type of `this` is the instance type (section [3.7.1](#3.7.1)) of this class type. The class type has the following members: * A property for each instance member variable declaration in the class body. * A property of a function type for each instance member function declaration in the class body. @@ -4112,7 +4335,7 @@ A class declaration declares a new named type (section [3.6](#3.6)) called a cla * An index signature for each instance index member declaration in the class body. * All base class instance type property or index members that are not overridden in the class. -All instance property members (including those that are private or protected) of a class must satisfy the constraints implied by the index members of the class as specified in section [3.8.4](#3.8.4). +All instance property members (including those that are private or protected) of a class must satisfy the constraints implied by the index members of the class as specified in section [3.9.4](#3.9.4). In the example @@ -4212,23 +4435,16 @@ Note that the construct signatures in the constructor function types have the sa A constructor declaration declares the constructor function of a class.   *ConstructorDeclaration:* -   *ConstructorOverloadsopt* *ConstructorImplementation* - -  *ConstructorOverloads:* -   *ConstructorOverload* -   *ConstructorOverloads* *ConstructorOverload* - -  *ConstructorOverload:* +   *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `{` *FunctionBody* `}`    *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `;` -  *ConstructorImplementation:* -   *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `{` *FunctionBody* `}` +Constructor declarations that specify a body are called ***constructor implementations*** and constructor declarations without a body are called ***constructor overloads***. It is possible to specify multiple constructor overloads in a class, but a class can have at most one constructor implementation. All constructor declarations in a class must specify the same set of modifiers. Only public constructors are supported and private or protected constructors result in an error. -A class may contain at most one constructor declaration. If a class contains no constructor declaration, an automatic constructor is provided, as described in section [8.3.3](#8.3.3). +In a class with no constructor declaration, an automatic constructor is provided, as described in section [8.3.3](#8.3.3). -Overloads and the implementation of a constructor may include an accessibility modifier, but only public constructors are supported and private or protected constructors result in an error. +When a class has constructor overloads, the overloads determine the construct signatures of the type given to the constructor function object, and the constructor implementation signature (if any) must be assignable to that type. Otherwise, the constructor implementation itself determines the construct signature. This exactly parallels the way overloads are processed in a function declaration (section [6.2](#6.2)). -If a constructor declaration includes overloads, the overloads determine the construct signatures of the type given to the constructor function object, and the constructor implementation signature must be assignable to that type. Otherwise, the constructor implementation itself determines the construct signature. This exactly parallels the way overloads are processed in a function declaration (section [6.2](#6.2)). +When a class has both constructor overloads and a constructor implementation, the overloads must precede the implementation and all of the declarations must be consecutive with no intervening grammatical elements. The function body of a constructor is permitted to contain return statements. If return statements specify expressions, those expressions must be of types that are assignable to the instance type of the class. @@ -4236,7 +4452,7 @@ The type parameters of a generic class are in scope and accessible in a construc ### 8.3.1 Constructor Parameters -Similar to functions, only the constructor implementation (and not constructor overloads) can specify default value expressions for optional parameters. It is a compile-time error for such default value expressions to reference `this`. For each parameter with a default value, a statement that substitutes the default value for an omitted argument is included in the JavaScript generated for the constructor function. +Similar to functions, only the constructor implementation (and not constructor overloads) can specify default value expressions for optional parameters. It is a compile-time error for such default value expressions to reference `this`. When the output target is ECMAScript 3 or 5, for each parameter with a default value, a statement that substitutes the default value for an omitted argument is included in the JavaScript generated for the constructor function. A parameter of a *ConstructorImplementation* may be prefixed with a `public`, `private`, or `protected` modifier. This is called a ***parameter property declaration*** and is shorthand for declaring a property with the same name as the parameter and initializing it with the value of the parameter. For example, the declaration @@ -4264,7 +4480,7 @@ class Point { ### 8.3.2 Super Calls -Super calls (section [4.8.1](#4.8.1)) are used to call the constructor of the base class. A super call consists of the keyword `super` followed by an argument list enclosed in parentheses. For example: +Super calls (section [4.9.1](#4.9.1)) are used to call the constructor of the base class. A super call consists of the keyword `super` followed by an argument list enclosed in parentheses. For example: ```TypeScript class ColoredPoint extends Point { @@ -4358,13 +4574,13 @@ var Point: { A member variable declaration declares an instance member variable or a static member variable.   *MemberVariableDeclaration:* -   *AccessibilityModifieropt* `static`*opt* *PropertyName* *TypeAnnotationopt* *Initialiseropt* `;` +   *AccessibilityModifieropt* `static`*opt* *PropertyName* *TypeAnnotationopt* *Initializeropt* `;` -The type associated with a member variable declaration is determined in the same manner as an ordinary variable declaration (see section [5.1](#5.1)). +The type associated with a member variable declaration is determined in the same manner as an ordinary variable declaration (see section [5.2](#5.2)). An instance member variable declaration introduces a member in the class instance type and optionally initializes a property on instances of the class. Initializers in instance member variable declarations are executed once for every new instance of the class and are equivalent to assignments to properties of `this` in the constructor. In an initializer expression for an instance member variable, `this` is of the class instance type. -A static member variable declaration introduces a property in the constructor function type and optionally initializes a property on the constructor function object. Initializers in static member variable declarations are executed once when the containing program or module is loaded. +A static member variable declaration introduces a property in the constructor function type and optionally initializes a property on the constructor function object. Initializers in static member variable declarations are executed once when the containing script or module is loaded. Initializer expressions for instance member variables are evaluated in the scope of the class constructor body but are not permitted to reference parameters or local variables of the constructor. This effectively means that entities from outer scopes by the same name as a constructor parameter or local variable are inaccessible in initializer expressions for instance member variables. @@ -4402,27 +4618,18 @@ class Employee { A member function declaration declares an instance member function or a static member function.   *MemberFunctionDeclaration:* -   *MemberFunctionOverloadsopt* *MemberFunctionImplementation* - -  *MemberFunctionOverloads*: -   *MemberFunctionOverload* -   *MemberFunctionOverloads* *MemberFunctionOverload* - -  *MemberFunctionOverload*: +   *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `{` *FunctionBody* `}`    *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `;` -  *MemberFunctionImplementation:* -   *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `{` *FunctionBody* `}` - A member function declaration is processed in the same manner as an ordinary function declaration (section [6](#6)), except that in a member function `this` has a known type. -All overloads of a member function must have the same accessibility (public, private, or protected) and kind (instance or static). +All declarations for the same member function must specify the same accessibility (public, private, or protected) and kind (instance or static). An instance member function declaration declares a property in the class instance type and assigns a function object to a property on the prototype object of the class. In the body of an instance member function declaration, `this` is of the class instance type. A static member function declaration declares a property in the constructor function type and assigns a function object to a property on the constructor function object. In the body of a static member function declaration, the type of `this` is the constructor function type. -A member function can access overridden base class members using a super property access (section [4.8.2](#4.8.2)). For example +A member function can access overridden base class members using a super property access (section [4.9.2](#4.9.2)). For example ```TypeScript class Point { @@ -4490,16 +4697,24 @@ A static member accessor declaration declares a property in the constructor func Get and set accessors are emitted as calls to 'Object.defineProperty' in the generated JavaScript, as described in section [8.6.1](#8.6.1). +### 8.4.4 Dynamic Property Declarations + +If the *PropertyName* of a property member declaration is a computed property name that doesn't denote a well-known symbol ([2.2.3](#2.2.3)), the construct is considered a ***dynamic property declaration***. The following rules apply to dynamic property declarations: + +* A dynamic property declaration does not introduce a property in the class instance type or constructor function type. +* The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. +* The name associated with a dynamic property declarations is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. + ## 8.5 Index Member Declarations -An index member declaration introduces an index signature (section [3.8.4](#3.8.4)) in the class instance type. +An index member declaration introduces an index signature (section [3.9.4](#3.9.4)) in the class instance type.   *IndexMemberDeclaration:*    *IndexSignature* `;` Index member declarations have no body and cannot specify an accessibility modifier. -A class declaration can have at most one string index member declaration and one numeric index member declaration. All instance property members of a class must satisfy the constraints implied by the index members of the class as specified in section [3.8.4](#3.8.4). +A class declaration can have at most one string index member declaration and one numeric index member declaration. All instance property members of a class must satisfy the constraints implied by the index members of the class as specified in section [3.9.4](#3.9.4). It is not possible to declare index members for the static side of a class. @@ -4507,7 +4722,7 @@ Note that it is seldom meaningful to include a string index signature in a class ## 8.6 Code Generation -This section describes the structure of the JavaScript code generated from TypeScript classes. +When the output target is ECMAScript 6 or higher, type parameters, implements clauses, accessibility modifiers, and member variable declarations are removed in the emitted code, but otherwise class declarations are emitted as written. When the output target is ECMAScript 3 or 5, more comprehensive rewrites are performed, as described in this section. ### 8.6.1 Classes Without Extends Clauses @@ -4696,14 +4911,14 @@ An enum type is a distinct subtype of the Number primitive type with an associat ## 9.1 Enum Declarations -An enum declaration declares an ***enum type*** and an ***enum object*** in the containing module. +An enum declaration declares an ***enum type*** and an ***enum object***.   *EnumDeclaration:* -   `const`*opt* `enum` *Identifier* `{` *EnumBodyopt* `}` +   `const`*opt* `enum` *BindingIdentifier* `{` *EnumBodyopt* `}` -The enum type and enum object declared by an *EnumDeclaration* both have the name given by the *Identifier* of the declaration. The enum type is a distinct subtype of the Number primitive type. The enum object is a variable of an anonymous object type containing a set of properties, all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. +An *EnumDeclaration* introduces a named type (the enum type) and a named value (the enum object) in the containing declaration space. The enum type is a distinct subtype of the Number primitive type. The enum object is a value of an anonymous object type containing a set of properties, all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. -The *Identifier* of an enum declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). +The *BindingIdentifier* of an enum declaration may not be one of the predefined type names (section [3.8.1](#3.8.1)). When an enum declaration includes a `const` modifier it is said to be a constant enum declaration. The members of a constant enum declaration must all have constant values that can be computed at compile time. Constant enum declarations are discussed in section [9.4](#9.4). @@ -4749,6 +4964,8 @@ The body of an enum declaration defines zero or more enum members which are the   *EnumValue:*    *AssignmentExpression* +The *PropertyName* of an enum member cannot be a computed property name ([2.2.3](#2.2.3)). + Enum members are either ***constant members*** or ***computed members***. Constant members have known constant values that are substituted in place of references to the members in the generated JavaScript code. Computed members have values that are computed at run-time and not known at compile-time. No substitution is performed for references to computed members. An enum member is classified as follows: @@ -4858,46 +5075,48 @@ var Color;
-#
10 Internal Modules +# 10 Namespaces -An internal module is a named container of statements and declarations. An internal module represents both a namespace and a singleton module instance. The namespace contains named types and other namespaces, and the singleton module instance contains properties for the module's exported members. The body of an internal module corresponds to a function that is executed once, thereby providing a mechanism for maintaining local state with assured isolation. +Namespaces provide a mechanism for organizing code and declarations in hierarchies of named containers. Namespaces have named members that each denote a value, a type, or a namespace, or some combination thereof, and those members may be local or exported. The body of a namespace corresponds to a function that is executed once, thereby providing a mechanism for maintaining local state with assured isolation. Namespaces can be thought of as a formalization of the [immediately-invoked function expression](https://en.wikipedia.org/wiki/Immediately-invoked_function_expression) (IIFE) pattern. -## 10.1 Module Declarations +## 10.1 Namespace Declarations -An internal module declaration declares a namespace name and, in the case of an instantiated module, a member name in the containing module. +A namespace declaration introduces a name with a namespace meaning and, in the case of an instantiated namespace, a value meaning in the containing declaration space. -  *ModuleDeclaration:* -   `module` *IdentifierPath* `{` *ModuleBody* `}` +  *NamespaceDeclaration:* +   `namespace` *IdentifierPath* `{` *NamespaceBody* `}`   *IdentifierPath:* -   *Identifier* -   *IdentifierPath* `.` *Identifier* +   *BindingIdentifier* +   *IdentifierPath* `.` *BindingIdentifier* -Internal modules are either ***instantiated*** or ***non-instantiated***. A non-instantiated module is an internal module containing only interface types and other non-instantiated modules. An instantiated module is an internal module that doesn't meet this definition. In intuitive terms, an instantiated module is one for which a module object instance is created, whereas a non-instantiated module is one for which no code is generated. +Namespaces are declared using the `namespace` keyword, but for backward compatibility of earlier versions of TypeScript a `module` keyword can also be used. -When a module identifier is referenced as a *ModuleName* (section [3.7.2](#3.7.2)) it denotes a container of module and type names, and when a module identifier is referenced as a *PrimaryExpression* (section [4.3](#4.3)) it denotes the singleton module instance. For example: +Namespaces are either ***instantiated*** or ***non-instantiated***. A non-instantiated namespace is a namespace containing only interface types, type aliases, and other non-instantiated namespace. An instantiated namespace is a namespace that doesn't meet this definition. In intuitive terms, an instantiated namespace is one for which a namespace instance is created, whereas a non-instantiated namespace is one for which no code is generated. + +When a namespace identifier is referenced as a *NamespaceName* (section [3.8.2](#3.8.2)) it denotes a container of namespace and type names, and when a namespace identifier is referenced as a *PrimaryExpression* (section [4.3](#4.3)) it denotes the singleton namespace instance. For example: ```TypeScript -module M { +namespace M { export interface P { x: number; y: number; } export var a = 1; } -var p: M.P; // M used as ModuleName +var p: M.P; // M used as NamespaceName var m = M; // M used as PrimaryExpression var x1 = M.a; // M used as PrimaryExpression var x2 = m.a; // Same as M.a var q: m.P; // Error ``` -Above, when 'M' is used as a *PrimaryExpression* it denotes an object instance with a single member 'a' and when 'M' is used as a *ModuleName* it denotes a container with a single type member 'P'. The final line in the example is an error because 'm' is a variable which cannot be referenced in a type name. +Above, when 'M' is used as a *PrimaryExpression* it denotes an object instance with a single member 'a' and when 'M' is used as a *NamespaceName* it denotes a container with a single type member 'P'. The final line in the example is an error because 'm' is a variable which cannot be referenced in a type name. -If the declaration of 'M' above had excluded the exported variable 'a', 'M' would be a non-instantiated module and it would be an error to reference 'M' as a *PrimaryExpression*. +If the declaration of 'M' above had excluded the exported variable 'a', 'M' would be a non-instantiated namespace and it would be an error to reference 'M' as a *PrimaryExpression*. -An internal module declaration that specifies an *IdentifierPath* with more than one identifier is equivalent to a series of nested single-identifier internal module declarations where all but the outermost are automatically exported. For example: +A namespace declaration that specifies an *IdentifierPath* with more than one identifier is equivalent to a series of nested single-identifier namespace declarations where all but the outermost are automatically exported. For example: ```TypeScript -module A.B.C { +namespace A.B.C { export var x = 1; } ``` @@ -4905,106 +5124,128 @@ module A.B.C { corresponds to ```TypeScript -module A { - export module B { - export module C { +namespace A { + export namespace B { + export namespace C { export var x = 1; } } } ``` -## 10.2 Module Body +The hierarchy formed by namespace and named type names partially mirrors that formed by namespace instances and members. The example -The body of an internal module corresponds to a function that is executed once to initialize the module instance. +```TypeScript +namespace A { + export namespace B { + export class C { } + } +} +``` -  *ModuleBody:* -   *ModuleElementsopt* +introduces a named type with the qualified name 'A.B.C' and also introduces a constructor function that can be accessed using the expression 'A.B.C'. Thus, in the example -  *ModuleElements:* -   *ModuleElement* -   *ModuleElements* *ModuleElement* +```TypeScript +var c: A.B.C = new A.B.C(); +``` -  *ModuleElement:* +the two occurrences of 'A.B.C' in fact refer to different entities. It is the context of the occurrences that determines whether 'A.B.C' is processed as a type name or an expression. + +## 10.2 Namespace Body + +The body of a namespace corresponds to a function that is executed once to initialize the namespace instance. + +  *NamespaceBody:* +   *NamespaceElementsopt* + +  *NamespaceElements:* +   *NamespaceElement* +   *NamespaceElements* *NamespaceElement* + +  *NamespaceElement:*    *Statement* -   `export`*opt* *VariableDeclaration* -   `export`*opt* *FunctionDeclaration* -   `export`*opt* *ClassDeclaration* -   `export`*opt* *InterfaceDeclaration* -   `export`*opt* *TypeAliasDeclaration* -   `export`*opt* *EnumDeclaration* -   `export`*opt* *ModuleDeclaration* -   `export`*opt* *ImportDeclaration* -   `export`*opt* *AmbientDeclaration* +   *LexicalDeclaration* +   *FunctionDeclaration* +   *GeneratorDeclaration* +   *ClassDeclaration* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* +   *NamespaceDeclaration +   AmbientDeclaration +   ImportAliasDeclaration +   ExportNamespaceElement* -Each module body has a declaration space for local variables (including functions, modules, class constructor functions, and enum objects), a declaration space for local named types (classes, interfaces, and enums), and a declaration space for local namespaces (containers of named types). Every declaration (whether local or exported) in a module contributes to one or more of these declaration spaces. +  *ExportNamespaceElement:* +   `export` *VariableStatement* +   `export` *LexicalDeclaration* +   `export` *FunctionDeclaration* +   `export` *GeneratorDeclaration* +   `export` *ClassDeclaration* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *EnumDeclaration* +   `export` *NamespaceDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* -## 10.3 Import Declarations +## 10.3 Import Alias Declarations -Import declarations are used to create local aliases for entities in other modules. +Import alias declarations are used to create local aliases for entities in other namespaces. -  *ImportDeclaration:* -   `import` *Identifier* `=` *EntityName* `;` +  *ImportAliasDeclaration:* +   `import` *BindingIdentifier* `=` *EntityName* `;`   *EntityName:* -   *ModuleName* -   *ModuleName* `.` *Identifier* +   *NamespaceName* +   *NamespaceName* `.` *IdentifierReference* -An *EntityName* consisting of a single identifier is resolved as a *ModuleName* and is thus required to reference an internal module. The resulting local alias references the given internal module and is itself classified as an internal module. +An *EntityName* consisting of a single identifier is resolved as a *NamespaceName* and is thus required to reference a namespace. The resulting local alias references the given namespace and is itself classified as a namespace. -An *EntityName* consisting of more than one identifier is resolved as a *ModuleName* followed by an identifier that names one or more exported entities in the given module. The resulting local alias has all the meanings and classifications of the referenced entity or entities. (As many as three distinct meanings are possible for an entity name—namespace, type, and member.) In effect, it is as if the imported entity or entities were declared locally with the local alias name. +An *EntityName* consisting of more than one identifier is resolved as a *NamespaceName* followed by an identifier that names an exported entity in the given namespace. The resulting local alias has all the meanings of the referenced entity. (As many as three distinct meanings are possible for an entity name—value, type, and namespace.) In effect, it is as if the imported entity was declared locally with the local alias name. In the example ```TypeScript -module A { +namespace A { export interface X { s: string } export var X: X; } -module B { +namespace B { interface A { n: number } - import Y = A; // Alias only for module A - import Z = A.X; // Alias for both type and member A.X + import Y = A; // Alias for namespace A + import Z = A.X; // Alias for type and value A.X var v: Z = Z; } ``` -within 'B', 'Y' is an alias only for module 'A' and not the local interface 'A', whereas 'Z' is an alias for all exported meanings of 'A.X', thus denoting both an interface type and a variable. +within 'B', 'Y' is an alias only for namespace 'A' and not the local interface 'A', whereas 'Z' is an alias for all exported meanings of 'A.X', thus denoting both an interface type and a variable. -If the *ModuleName* portion of an *EntityName* references an instantiated module, the *ModuleName* is required to reference the module instance when evaluated as an expression. In the example +If the *NamespaceName* portion of an *EntityName* references an instantiated namespace, the *NamespaceName* is required to reference the namespace instance when evaluated as an expression. In the example ```TypeScript -module A { +namespace A { export interface X { s: string } } -module B { +namespace B { var A = 1; import Y = A; } ``` -'Y' is a local alias for the non-instantiated module 'A'. If the declaration of 'A' is changed such that 'A' becomes an instantiated module, for example by including a variable declaration in 'A', the import statement in 'B' above would be an error because the expression 'A' doesn't reference the module instance of module 'A'. +'Y' is a local alias for the non-instantiated namespace 'A'. If the declaration of 'A' is changed such that 'A' becomes an instantiated namespace, for example by including a variable declaration in 'A', the import statement in 'B' above would be an error because the expression 'A' doesn't reference the namespace instance of namespace 'A'. When an import statement includes an export modifier, all meanings of the local alias are exported. ## 10.4 Export Declarations -An export declaration declares an externally accessible module member. An export declaration is simply a regular declaration prefixed with the keyword `export`. +An export declaration declares an externally accessible namespace member. An export declaration is simply a regular declaration prefixed with the keyword `export`. -Exported class, interface, and enum types can be accessed as a *TypeName* (section [3.7.2](#3.7.2)) of the form *M.T*, where *M* is a reference to the containing module and *T* is the exported type name. Likewise, as part of a *TypeName*, exported modules can be accessed as a *ModuleName* of the form *M.N*, where *M* is a reference to the containing module and *N* is the exported module. +The members of a namespace's export declaration space (section [2.3](#2.3)) constitute the namespace's ***export member set***. A namespace's ***instance type*** is an object type with a property for each member in the namespace's export member set that denotes a value. -Exported variable, function, class, enum, module, and import alias declarations become properties on the module instance and together establish the module's ***instance type***. This unnamed type has the following members: - -* A property for each exported variable declaration. -* A property of a function type for each exported function declaration. -* A property of a constructor type for each exported class declaration. -* A property of an object type for each exported enum declaration. -* A property of an object type for each exported instantiated module declaration. -* A property for each exported import alias that references a variable, function, class, enum, or instantiated module. - -An exported member depends on a (possibly empty) set of named types (section [3.6](#3.6)). Those named types must be at least as accessible as the exported member, or otherwise an error occurs. +An exported member depends on a (possibly empty) set of named types (section [3.7](#3.7)). Those named types must be at least as accessible as the exported member, or otherwise an error occurs. The named types upon which a member depends are the named types occurring in the transitive closure of the ***directly depends on*** relationship defined as follows: @@ -5012,40 +5253,40 @@ The named types upon which a member depends are the named types occurring in the * A function directly depends on each *Type* specified in a parameter or return type annotation. * A class directly depends on each *Type* specified as a type parameter constraint, each *TypeReference* specified as a base class or implemented interface, and each *Type* specified in a constructor parameter type annotation, public member variable type annotation, public member function parameter or return type annotation, public member accessor parameter or return type annotation, or index signature type annotation. * An interface directly depends on each *Type* specified as a type parameter constraint, each *TypeReference* specified as a base interface, and the *ObjectType* specified as its body. -* A module directly depends on its exported members. +* A namespace directly depends on its exported members. * A *Type* or *ObjectType* directly depends on every *TypeReference* that occurs within the type at any level of nesting. * A *TypeReference* directly depends on the type it references and on each *Type* specified as a type argument. -A named type *T* having a root module *R* (section [2.3](#2.3)) is said to be ***at least as accessible as*** a member *M* if +A named type *T* having a root namespace *R* (section [2.3](#2.3)) is said to be ***at least as accessible as*** a member *M* if -* *R* is the global module or an external module, or -* *R* is an internal module in the parent module chain of *M*. +* *R* is the global namespace or a module, or +* *R* is a namespace in the parent namespace chain of *M*. In the example ```TypeScript interface A { x: string; } -module M { +namespace M { export interface B { x: A; } export interface C { x: B; } export function foo(c: C) { … } } ``` -the 'foo' function depends upon the named types 'A', 'B', and 'C'. In order to export 'foo' it is necessary to also export 'B' and 'C' as they otherwise would not be at least as accessible as 'foo'. The 'A' interface is already at least as accessible as 'foo' because it is declared in a parent module of foo's module. +the 'foo' function depends upon the named types 'A', 'B', and 'C'. In order to export 'foo' it is necessary to also export 'B' and 'C' as they otherwise would not be at least as accessible as 'foo'. The 'A' interface is already at least as accessible as 'foo' because I t is declared in a parent namespace of foo's namespace. ## 10.5 Declaration Merging -Internal modules are "open-ended" and internal module declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single module. For example, the following two declarations of a module outer might be located in separate source files. +Namespaces are "open-ended" and namespace declarations with the same qualified name relative to a common root (as defined in section [2.3](#2.3)) contribute to a single namespace. For example, the following two declarations of a namespace 'outer' might be located in separate source files. File a.ts: ```TypeScript -module outer { +namespace outer { var local = 1; // Non-exported local variable export var a = local; // outer.a - export module inner { + export namespace inner { export var x = 10; // outer.inner.x } } @@ -5054,16 +5295,16 @@ module outer { File b.ts: ```TypeScript -module outer { +namespace outer { var local = 2; // Non-exported local variable export var b = local; // outer.b - export module inner { + export namespace inner { export var y = 20; // outer.inner.y } } ``` -Assuming the two source files are part of the same program, the two declarations will have the global module as their common root and will therefore contribute to the same module instance, the instance type of which will be: +Assuming the two source files are part of the same program, the two declarations will have the global namespace as their common root and will therefore contribute to the same namespace instance, the instance type of which will be: ```TypeScript { @@ -5076,15 +5317,17 @@ Assuming the two source files are part of the same program, the two declarations } ``` -Declaration merging does not apply to local aliases created by import declarations. In other words, it is not possible have an import declaration and a module declaration for the same name within the same module body. +Declaration merging does not apply to local aliases created by import alias declarations. In other words, it is not possible have an import alias declaration and a namespace declaration for the same name within the same namespace body. -Declaration merging also extends to internal module declarations with the same qualified name relative to a common root as a function, class, or enum declaration: +*TODO: Clarify rules for [alias resolution](https://github.com/Microsoft/TypeScript/issues/3158)*. -* When merging a function and an internal module, the type of the function object is merged with the instance type of the module. In effect, the overloads or implementation of the function provide the call signatures and the exported members of the module provide the properties of the combined type. -* When merging a class and an internal module, the type of the constructor function object is merged with the instance type of the module. In effect, the overloads or implementation of the class constructor provide the construct signatures, and the static members of the class and exported members of the module provide the properties of the combined type. It is an error to have static class members and exported module members with the same name. -* When merging an enum and an internal module, the type of the enum object is merged with the instance type of the module. In effect, the members of the enum and the exported members of the module provide the properties of the combined type. It is an error to have enum members and exported module members with the same name. +Declaration merging also extends to namespace declarations with the same qualified name relative to a common root as a function, class, or enum declaration: -When merging a non-ambient function or class declaration and a non-ambient internal module declaration, the function or class declaration must be located prior to the internal module declaration in the same source file. This ensures that the shared object instance is created as a function object. (While it is possible to add properties to an object after its creation, it is not possible to make an object "callable" after the fact.) +* When merging a function and a namespace, the type of the function object is merged with the instance type of the namespace. In effect, the overloads or implementation of the function provide the call signatures and the exported members of the namespace provide the properties of the combined type. +* When merging a class and a namespace, the type of the constructor function object is merged with the instance type of the namespace. In effect, the overloads or implementation of the class constructor provide the construct signatures, and the static members of the class and exported members of the namespace provide the properties of the combined type. It is an error to have static class members and exported namespace members with the same name. +* When merging an enum and a namespace, the type of the enum object is merged with the instance type of the namespace. In effect, the members of the enum and the exported members of the namespace provide the properties of the combined type. It is an error to have enum members and exported namespace members with the same name. + +When merging a non-ambient function or class declaration and a non-ambient namespace declaration, the function or class declaration must be located prior to the namespace declaration in the same source file. This ensures that the shared object instance is created as a function object. (While it is possible to add properties to an object after its creation, it is not possible to make an object "callable" after the fact.) The example @@ -5098,7 +5341,7 @@ function point(x: number, y: number): Point { return { x: x, y: y }; } -module point { +namespace point { export var origin = point(0, 0); export function equals(p1: Point, p2: Point) { return p1.x == p2.x && p1.y == p2.y; @@ -5110,20 +5353,20 @@ var p2 = point.origin; var b = point.equals(p1, p2); ``` -declares 'point' as a function object with two properties, 'origin' and 'equals'. Note that the module declaration for 'point' is located after the function declaration. +declares 'point' as a function object with two properties, 'origin' and 'equals'. Note that the namespace declaration for 'point' is located after the function declaration. ## 10.6 Code Generation -An internal module generates JavaScript code that is equivalent to the following: +A namespace generates JavaScript code that is equivalent to the following: ```TypeScript -var ; -(function() { - -})(||(={})); +var ; +(function() { + +})(||(={})); ``` -where *ModuleName* is the name of the module and *ModuleStatements* is the code generated for the statements in the module body. The *ModuleName* function parameter may be prefixed with one or more underscore characters to ensure the name is unique within the function body. Note that the entire module is emitted as an anonymous function that is immediately executed. This ensures that local variables are in their own lexical environment isolated from the surrounding context. Also note that the generated function doesn't create and return a module instance, but rather it extends the existing instance (which may have just been created in the function call). This ensures that internal modules can extend each other. +where *NamespaceName* is the name of the namespace and *NamespaceStatements* is the code generated for the statements in the namespace body. The *NamespaceName* function parameter may be prefixed with one or more underscore characters to ensure the name is unique within the function body. Note that the entire namespace is emitted as an anonymous function that is immediately executed. This ensures that local variables are in their own lexical environment isolated from the surrounding context. Also note that the generated function doesn't create and return a namespace instance, but rather it extends the existing instance (which may have just been created in the function call). This ensures that namespaces can extend each other. An import statement generates code of the form @@ -5131,182 +5374,428 @@ An import statement generates code of the form var = ; ``` -This code is emitted only if the imported entity is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported entity is referenced only as a *TypeName* or *ModuleName*, nothing is emitted. This ensures that types declared in one internal module can be referenced through an import alias in another internal module with no run-time overhead. +This code is emitted only if the imported entity is referenced as a *PrimaryExpression* somewhere in the body of the importing namespace. If an imported entity is referenced only as a *TypeName* or *NamespaceName*, nothing is emitted. This ensures that types declared in one namespace can be referenced through an import alias in another namespace with no run-time overhead. -When a variable is exported, all references to the variable in the body of the module are replaced with +When a variable is exported, all references to the variable in the body of the namespace are replaced with ```TypeScript -. +. ``` -This effectively promotes the variable to be a property on the module instance and ensures that all references to the variable become references to the property. +This effectively promotes the variable to be a property on the namespace instance and ensures that all references to the variable become references to the property. -When a function, class, enum, or module is exported, the code generated for the entity is followed by an assignment statement of the form +When a function, class, enum, or namespace is exported, the code generated for the entity is followed by an assignment statement of the form ```TypeScript -. = ; +. = ; ``` -This copies a reference to the entity into a property on the module instance. +This copies a reference to the entity into a property on the namespace instance.
-#
11 Source Files and External Modules +# 11 Scripts and Modules -TypeScript implements external modules that are closely aligned with those proposed for ECMAScript 6 and supports code generation targeting CommonJS and AMD module systems. +TypeScript implements support for ECMAScript 6 modules and supports down-level code generation targeting CommonJS, AMD, and other module systems. -*NOTE: TypeScript currently doesn't support the full proposed capabilities of the ECMAScript 6 import and export syntax. We expect to align more closely on the syntax as the ECMAScript 6 specification evolves*. +## 11.1 Programs and Source Files -## 11.1 Source Files - -A TypeScript ***program*** consists of one or more source files that are either ***implementation source files*** or ***declaration source files***. Source files with extension '.ts' are *ImplementationSourceFiles* containing statements and declarations. Source files with extension '.d.ts' are *DeclarationSourceFiles* containing declarations only. Declaration source files are a strict subset of implementation source files. +A TypeScript ***program*** consists of one or more source files.   *SourceFile:*    *ImplementationSourceFile*    *DeclarationSourceFile*   *ImplementationSourceFile:* -   *ImplementationElementsopt* - -  *ImplementationElements:* -   *ImplementationElement* -   *ImplementationElements* *ImplementationElement* - -  *ImplementationElement:* -   *ModuleElement* -   *ExportAssignment* -   *AmbientExternalModuleDeclaration* -   `export`*opt* *ExternalImportDeclaration* +   *ImplementationScript* +   *ImplementationModule*   *DeclarationSourceFile:* -   *DeclarationElementsopt* +   *DeclarationScript* +   *DeclarationModule* -  *DeclarationElements:* -   *DeclarationElement* -   *DeclarationElements* *DeclarationElement* +Source files with extension '.ts' are ***implementation source files*** containing statements and declarations, and source files with extension '.d.ts' are ***declaration source files*** containing declarations only. -  *DeclarationElement:* -   *ExportAssignment* -   *AmbientExternalModuleDeclaration* -   `export`*opt* *InterfaceDeclaration* -   `export`*opt* *TypeAliasDeclaration* -   `export`*opt* *ImportDeclaration* -   `export`*opt* *AmbientDeclaration* -   `export`*opt* *ExternalImportDeclaration* +Declaration source files are a strict subset of implementation source files and are used to declare the static type information associated with existing JavaScript code in an adjunct manner. They are entirely optional but enable the TypeScript compiler and tools to provide better verification and assistance when integrating existing JavaScript code and libraries in a TypeScript application. When a TypeScript program is compiled, all of the program's source files are processed together. Statements and declarations in different source files can depend on each other, possibly in a circular fashion. By default, a JavaScript output file is generated for each implementation source file in a compilation, but no output is generated from declaration source files. -The source elements permitted in a TypeScript implementation source file are a superset of those supported by JavaScript. Specifically, TypeScript extends the JavaScript grammar's existing *VariableDeclaration* (section [5.1](#5.1)) and *FunctionDeclaration* (section [6.1](#6.1)) productions, and adds *TypeAliasDeclaration* (section [3.9](#3.9)), *InterfaceDeclaration* (section [7.1](#7.1)), *ClassDeclaration* (section [8.1](#8.1)), *EnumDeclaration* (section [9.1](#9.1)), *ModuleDeclaration* (section [10.1](#10.1)), *ImportDeclaration* (section [10.3](#10.3)), *ExternalImportDeclaration* (section [11.2.2](#11.2.2)), *ExportAssignment* (section [11.2.4](#11.2.4)), *AmbientDeclaration* (section [12.1](#12.1)), and *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) productions. - -Declaration source files are restricted to contain declarations only. Declaration source files can be used to declare the static type information associated with existing JavaScript code in an adjunct manner. They are entirely optional but enable the TypeScript compiler and tools to provide better verification and assistance when integrating existing JavaScript code and libraries in a TypeScript application. - -Implementation and declaration source files that contain no import or export declarations form the single ***global module***. Entities declared in the global module are in scope everywhere in a program. Initialization order of the source files that make up the global module ultimately depends on the order in which the generated JavaScript files are loaded at run-time (which, for example, may be controlled by <script/> tags that reference the generated JavaScript files). - -Implementation and declaration source files that contain at least one external import declaration, export assignment, or top-level exported declaration are considered separate ***external modules***. Entities declared in an external module are in scope only in that module, but exported entities can be imported into other modules using import declarations. Initialization order of external modules is determined by the module loader being and is not specified by the TypeScript language. However, it is generally the case that non-circularly dependent modules are automatically loaded and initialized in the correct order. - -External modules can additionally be declared using *AmbientExternalModuleDeclarations* in the global module that directly specify the external module names as string literals. This is described further in section [12.2](#12.2). - ### 11.1.1 Source Files Dependencies -The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. The determination is made from "reference comments" and external import declarations as follows: +The TypeScript compiler automatically determines a source file's dependencies and includes those dependencies in the program being compiled. The determination is made from "reference comments" and module import declarations as follows: * A comment of the form /// <reference path="…"/> adds a dependency on the source file specified in the path argument. The path is resolved relative to the directory of the containing source file. -* An external import declaration that specifies a relative external module name (section [11.2.1](#11.2.1)) resolves the name relative to the directory of the containing source file. If a source file with the resulting path and file extension '.ts' exists, that file is added as a dependency. Otherwise, if a source file with the resulting path and file extension '.d.ts' exists, that file is added as a dependency. -* An external import declaration that specifies a top-level external module name (section [11.2.1](#11.2.1)) resolves the name in a host dependent manner (typically by resolving the name relative to a module name space root or searching for the name in a series of directories). If a source file with extension '.ts' or '.d.ts' corresponding to the reference is located, that file is added as a dependency. +* A module import declaration that specifies a relative module name (section [11.3.1](#11.3.1)) resolves the name relative to the directory of the containing source file. If a source file with the resulting path and file extension '.ts' exists, that file is added as a dependency. Otherwise, if a source file with the resulting path and file extension '.d.ts' exists, that file is added as a dependency. +* A module import declaration that specifies a top-level module name (section [11.3.1](#11.3.1)) resolves the name in a host dependent manner (typically by resolving the name relative to a module name space root or searching for the name in a series of directories). If a source file with extension '.ts' or '.d.ts' corresponding to the reference is located, that file is added as a dependency. Any files included as dependencies in turn have their references analyzed in a transitive manner until all dependencies have been determined. -## 11.2 External Modules +## 11.2 Scripts -External modules are separately loaded bodies of code referenced using external module names. External modules can be likened to functions that are loaded and executed once to initialize their associated module instance. Entities declared in an external module are private and inaccessible elsewhere unless they are exported. +Source files that contain no module import or export declarations are classified as ***scripts***. Scripts form the single ***global namespace*** and entities declared in scripts are in scope everywhere in a program. -External modules are written as separate source files that contain at least one external import declaration, export assignment, or top-level exported declaration. Specifically, if a source file contains at least one +  *ImplementationScript:* +   *ImplementationScriptElementsopt* -* *ExternalImportDeclaration*, -* *ExportAssignment*, -* top-level exported *VariableDeclaration*, -* top-level exported *FunctionDeclaration*, -* top-level exported *ClassDeclaration*, -* top-level exported *InterfaceDeclaration*, -* top-level exported *TypeAliasDeclaration*, -* top-level exported *EnumDeclaration*, -* top-level exported *ModuleDeclaration*, -* top-level exported *ImportDeclaration*, or -* top-level exported *AmbientDeclaration*, +  *ImplementationScriptElements:* +   *ImplementationScriptElement* +   *ImplementationScriptElements* *ImplementationScriptElement* -that source file is considered an external module; otherwise, the source file is considered part of the global module. +  *ImplementationScriptElement:* +   *ImplementationElement* +   *AmbientModuleDeclaration* -Below is an example of two external modules written in separate source files. +  *ImplementationElement:* +   *Statement* +   *LexicalDeclaration* +   *FunctionDeclaration* +   *GeneratorDeclaration* +   *ClassDeclaration* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* +   *NamespaceDeclaration* +   *AmbientDeclaration* +   *ImportAliasDeclaration* -File main.ts: +  *DeclarationScript:* +   *DeclarationScriptElementsopt* + +  *DeclarationScriptElements:* +   *DeclarationScriptElement* +   *DeclarationScriptElements* *DeclarationScriptElement* + +  *DeclarationScriptElement:* +   *DeclarationElement* +   *AmbientModuleDeclaration* + +  *DeclarationElement:* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *NamespaceDeclaration* +   *AmbientDeclaration* +   *ImportAliasDeclaration* + +The initialization order of the scripts that make up the global namespace ultimately depends on the order in which the generated JavaScript files are loaded at run-time (which, for example, may be controlled by <script/> tags that reference the generated JavaScript files). + +## 11.3 Modules + +Source files that contain at least one module import or export declaration are considered separate ***modules***. Non-exported entities declared in a module are in scope only in that module, but exported entities can be imported into other modules using import declarations. + +  *ImplementationModule:* +   *ImplementationModuleElementsopt* + +  *ImplementationModuleElements:* +   *ImplementationModuleElement* +   *ImplementationModuleElements* *ImplementationModuleElement* + +  *ImplementationModuleElement:* +   *ImplementationElement* +   *ImportDeclaration* +   *ImportAliasDeclaration* +   *ImportRequireDeclaration* +   *ExportImplementationElement* +   *ExportDefaultImplementationElement* +   *ExportListDeclaration* +   *ExportAssignment* + +  *DeclarationModule:* +   *DeclarationModuleElementsopt* + +  *DeclarationModuleElements:* +   *DeclarationModuleElement* +   *DeclarationModuleElements* *DeclarationModuleElement* + +  *DeclarationModuleElement:* +   *DeclarationElement* +   *ImportDeclaration* +   *ImportAliasDeclaration* +   *ExportDeclarationElement* +   *ExportDefaultDeclarationElement* +   *ExportListDeclaration* +   *ExportAssignment* + +Initialization order of modules is determined by the module loader being used and is not specified by the TypeScript language. However, it is generally the case that non-circularly dependent modules are automatically loaded and initialized in the correct order. + +Modules can additionally be declared using *AmbientModuleDeclarations* in declaration scripts that directly specify the module names as string literals. This is described further in section [12.2](#12.2). + +Below is an example of two modules written in separate source files: ```TypeScript -import log = require("./log"); -log.message("hello"); -``` +// -------- main.ts -------- +import { message } from "./log"; +message("hello"); -File log.ts: - -```TypeScript +// -------- log.ts -------- export function message(s: string) { console.log(s); } ``` -The import declaration in the 'main' module references the 'log' module and compiling the 'main.ts' file causes the 'log.ts' file to also be compiled as part of the program. At run-time, the import declaration loads the 'log' module and produces a reference to its module instance through which it is possible to reference the exported function. +The import declaration in the 'main' module references the 'log' module and compiling the 'main.ts' file causes the 'log.ts' file to also be compiled as part of the program. -TypeScript supports two patterns of JavaScript code generation for external modules: The CommonJS Modules pattern (section [11.2.5](#11.2.5)), typically used by server frameworks such as node.js, and the Asynchronous Module Definition (AMD) pattern (section [11.2.6](#11.2.6)), an extension to CommonJS Modules that permits asynchronous module loading, as is typical in browsers. The desired module code generation pattern is selected through a compiler option and does not affect the TypeScript source code. Indeed, it is possible to author external modules that can be compiled for use both on the server side (e.g. using node.js) and on the client side (using an AMD compliant loader) with no changes to the TypeScript source code. +TypeScript supports multiple patterns of JavaScript code generation for modules: -### 11.2.1 External Module Names +* CommonJS. This format is used by server frameworks such as node.js. +* AMD (Asynchronous Module Definition). This format is used by asynchronous module loaders such as RequireJS. +* UMD (Universal Module Definition). A variation of the AMD format that allows modules to also be loaded by CommonJS loaders. +* System. This format is used to represent ECMAScript 6 semantics with high fidelity in down-level environments. -External modules are identified and referenced using external module names. The following definition is aligned with that provided in the CommonJS Modules 1.0 specification. +The desired module code generation pattern is selected through a compiler option and does not affect the TypeScript source code. Indeed, it is possible to author modules that can be compiled for use both on the server side (e.g. using node.js) and on the client side (using an AMD compliant loader) with no changes to the TypeScript source code. -* An external module name is a string of terms delimited by forward slashes. -* External module names may not have file-name extensions like ".js". -* External module names may be relative or top-level. An external module name is relative if the first term is "." or "..". +### 11.3.1 Module Names + +Modules are identified and referenced using module names. The following definition is aligned with that provided in the [CommonJS Modules](http://www.commonjs.org/specs/modules/1.0/) 1.0 specification. + +* A module name is a string of terms delimited by forward slashes. +* Module names may not have file-name extensions like ".js". +* Module names may be relative or top-level. A module name is relative if the first term is "." or "..". * Top-level names are resolved off the conceptual module name space root. * Relative names are resolved relative to the name of the module in which they occur. -For purposes of resolving external module references, TypeScript associates a file path with every external module. The file path is simply the path of the module's source file without the file extension. For example, an external module contained in the source file 'C:\src\lib\io.ts' has the file path 'C:/src/lib/io' and an external module contained in the source file 'C:\src\ui\editor.d.ts' has the file path 'C:/src/ui/editor'. +For purposes of resolving module references, TypeScript associates a file path with every module. The file path is simply the path of the module's source file without the file extension. For example, a module contained in the source file 'C:\src\lib\io.ts' has the file path 'C:/src/lib/io' and a module contained in the source file 'C:\src\ui\editor.d.ts' has the file path 'C:/src/ui/editor'. -An external module name in an import declaration is resolved as follows: +A module name in an import declaration is resolved as follows: -* If the import declaration specifies a relative external module name, the name is resolved relative to the directory of the referencing module's file path. The program must contain a module with the resulting file path or otherwise an error occurs. For example, in a module with the file path 'C:/src/ui/main', the external module names './editor' and '../lib/io' reference modules with the file paths 'C:/src/ui/editor' and 'C:/src/lib/io'. -* If the import declaration specifies a top-level external module name and the program contains an *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, then the import declaration references that ambient external module. -* If the import declaration specifies a top-level external module name and the program contains no *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, the name is resolved in a host dependent manner (for example by considering the name relative to a module name space root). If a matching module cannot be found an error occurs. +* If the import declaration specifies a relative module name, the name is resolved relative to the directory of the referencing module's file path. The program must contain a module with the resulting file path or otherwise an error occurs. For example, in a module with the file path 'C:/src/ui/main', the module names './editor' and '../lib/io' reference modules with the file paths 'C:/src/ui/editor' and 'C:/src/lib/io'. +* If the import declaration specifies a top-level module name and the program contains an *AmbientModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, then the import declaration references that ambient module. +* If the import declaration specifies a top-level module name and the program contains no *AmbientModuleDeclaration* (section [12.2](#12.2)) with a string literal that specifies that exact name, the name is resolved in a host dependent manner (for example by considering the name relative to a module name space root). If a matching module cannot be found an error occurs. -### 11.2.2 External Import Declarations +### 11.3.2 Import Declarations -External import declarations are used to import external modules and create local aliases by which they may be referenced. +Import declarations are used to import entities from other modules and provide bindings for them in the current module. -  *ExternalImportDeclaration:* -   `import` *Identifier* `=` *ExternalModuleReference* `;` +An import declaration of the form -  *ExternalModuleReference:* -   `require` `(` *StringLiteral* `)` +```TypeScript +import * as m from "mod"; +``` -The string literal specified in an *ExternalModuleReference* is interpreted as an external module name (section [11.2.1](#11.2.1)). +imports the module with the given name and creates a local binding for the module itself. The local binding is classified as a value (representing the module instance) and a namespace (representing a container of types and namespaces). -An external import declaration introduces a local identifier that references a given external module. The local identifier becomes an alias for, and is classified exactly like, the entity or entities exported from the referenced external module. Specifically, if the referenced external module contains no export assignment the identifier is classified as a module, and if the referenced external module contains an export assignment the identifier is classified exactly like the entity or entities named in the export assignment. +An import declaration of the form -### 11.2.3 Export Declarations +```TypeScript +import { x, y, z } from "mod"; +``` -An external module that contains no export assignment (section [11.2.4](#11.2.4)) exports an entity classified as a module. Similarly to an internal module, export declarations (section [10.4](#10.4)) in the external module are used to declare the members of this entity. +imports a given module and creates local bindings for a specified list of exported members of the module. The specified names must each reference an entity in the export member set ([11.3.4.4](#11.3.4.4)) of the given module. The local bindings have the same names and classifications as the entities they represent unless `as` clauses are used to that specify different local names: -Unlike a non-instantiated internal module (section [10.1](#10.1)), an external module containing only interface types and non-instantiated internal modules still has a module instance associated with it, albeit one with no members. +```TypeScript +import { x as a, y as b } from "mod"; +``` -If an external module contains an export assignment it is an error for the external module to also contain export declarations. The two types of exports are mutually exclusive. +An import declaration of the form -### 11.2.4 Export Assignments +```TypeScript +import d from "mod"; +``` -An export assignment designates a module member as the entity to be exported in place of the external module itself. +is exactly equivalent to the import declaration + +```TypeScript +import { default as d } from "mod"; +``` + +An import declaration of the form + +```TypeScript +import "mod"; +``` + +imports the given module without creating any local bindings (this is useful only if the imported module has side effects). + +### 11.3.3 Import Require Declarations + +Import require declarations exist for backward compatibility with earlier versions of TypeScript. + +  *ImportRequireDeclaration:* +   `import` *BindingIdentifier* `=` `require` `(` *StringLiteral* `)` `;` + +An import require declaration introduces a local identifier that references a given module. The string literal specified in an import require declaration is interpreted as a module name (section [11.3.1](#11.3.1)). The local identifier introduced by the declaration becomes an alias for, and is classified exactly like, the entity exported from the referenced module. Specifically, if the referenced module contains no export assignment the identifier is classified as a value and a namespace, and if the referenced module contains an export assignment the identifier is classified exactly like the entity named in the export assignment. + +An import require declaration of the form + +```TypeScript +import m = require("mod"); +``` + +is equivalent to the ECMAScript 6 import declaration + +```TypeScript +import * as m from "mod"; +``` + +provided the referenced module contains no export assignment. + +### 11.3.4 Export Declarations + +An export declaration declares one or more exported module members. The exported members of a module can be imported in other modules using import declarations ([11.3.2](#11.3.2)). + +#### 11.3.4.1 Export Modifiers + +In the body of a module, a declaration can export the declared entity by including an `export` modifier. + +  *ExportImplementationElement:* +   `export` *VariableStatement* +   `export` *LexicalDeclaration* +   `export` *FunctionDeclaration* +   `export` *GeneratorDeclaration* +   `export` *ClassDeclaration* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *EnumDeclaration* +   `export` *NamespaceDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* + +  *ExportDeclarationElement:* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* + +In addition to introducing a name in the local declaration space of the module, an exported declaration introduces the same name with the same classification in the module's export declaration space. For example, the declaration + +```TypeScript +export function point(x: number, y: number) { + return { x, y }; +} +``` + +introduces a local name `point` and an exported name `point` that both reference the function. + +#### 11.3.4.2 Export Default Declarations + +Export default declarations provide short-hand syntax for exporting an entity named `default`. + +  *ExportDefaultImplementationElement:* +   `export` `default` *FunctionDeclaration* +   `export` `default` *GeneratorDeclaration* +   `export` `default` *ClassDeclaration* +   `export` `default` *AssignmentExpression* `;` + +  *ExportDefaultDeclarationElement:* +   `export` `default` *AmbientFunctionDeclaration* +   `export` `default` *AmbientClassDeclaration* +   `export` `default` *IdentifierReference* `;` + +An *ExportDefaultImplementationElement* or *ExportDefaultDeclarationElement* for a function, generator, or class introduces a value named `default`, and in the case of a class, a type named `default`, in the containing module's export declaration space. The declaration may optionally specify a local name for the exported function, generator, or class. For example, the declaration + +```TypeScript +export default function point(x: number, y: number) { + return { x, y }; +} +``` + +introduces a local name `point` and an exported name `default` that both reference the function. The declaration is effectively equivalent to + +```TypeScript +function point(x: number, y: number) { + return { x, y }; +} + +export default point; +``` + +which again is equivalent to + +```TypeScript +function point(x: number, y: number) { + return { x, y }; +} + +export { point as default }; +``` + +An *ExportDefaultImplementationElement* or *ExportDefaultDeclarationElement* for an expression consisting of a single identifier must name an entity declared in the current module or the global namespace. The declaration introduces an entity named `default`, with the same classification as the referenced entity, in the containing module's export declaration space. For example, the declarations + +```TypeScript +interface Point { + x: number; + y: number; +} + +function Point(x: number, y: number): Point { + return { x, y }; +} + +export default Point; +``` + +introduce a local name `Point` and an exported name `default`, both with a value and a type meaning. + +An *ExportDefaultImplementationElement* for any expression but a single identifier introduces a value named `default` in the containing module's export declaration space. For example, the declaration + +```TypeScript +export default "hello"; +``` + +introduces an exported value named `default` of type string. + +#### 11.3.4.3 Export List Declarations + +An export list declaration exports one or more entities from the current module or a specified module. + +  *ExportListDeclaration:* +   `export` `*` *FromClause* `;` +   `export` *ExportClause* *FromClause* `;` +   `export` *ExportClause* `;` + +An *ExportListDeclaration* without a *FromClause* exports entities from the current module. In a declaration of the form + +```TypeScript +export { x }; +``` + +the name `x` must reference an entity declared in the current module or the global namespace, and the declaration introduces an entity with the same name and meaning in the containing module's export declaration space. + +An *ExportListDeclaration* with a *FromClause* re-exports entities from a specified module. In a declaration of the form + +```TypeScript +export { x } from "mod"; +``` + +the name `x` must reference an entity in the export member set of the specified module, and the declaration introduces an entity with the same name and meaning in the containing module's export declaration space. No local bindings are created for `x`. + +The *ExportClause* of an *ExportListDeclaration* can specify multiple entities and may optionally specify different names to be used for the exported entities. For example, the declaration + +```TypeScript +export { x, y as b, z as c }; +``` + +introduces entities named `x`, `b`, and `c` in the containing module's export declaration space with the same meaning as the local entities named `x`, `y`, and `z` respectively. + +An *ExportListDeclaration* that specifies `*` instead of an *ExportClause* is called an ***export star*** declaration. An export star declaration re-exports all members of a specified module. + +```TypeScript +export * from "mod"; +``` + +Explicitly exported members take precedence over members re-exported using export star declarations, as described in the following section. + +#### 11.3.4.4 Export Member Set + +The ***export member set*** of a particular module is determined by starting with an empty set of members *E* and an empty set of processed modules *P*, and then processing the module as described below to form the full set of exported members in *E*. Processing a module *M* consists of these steps: + +* Add *M* to *P*. +* Add to *E* each member in the export declaration space of *M* with a name that isn't already in *E*. +* For each export star declaration in *M*, in order of declaration, process the referenced module if it is not already in *P*. + +A module's ***instance type*** is an object type with a property for each member in the module's export member set that denotes a value. + +If a module contains an export assignment it is an error for the module to also contain export declarations. The two types of exports are mutually exclusive. + +### 11.3.5 Export Assignments + +Export assignments exist for backward compatibility with earlier versions of TypeScript. An export assignment designates a module member as the entity to be exported in place of the module itself.   *ExportAssignment:* -   `export` `=` *Identifier* `;` +   `export` `=` *IdentifierReference* `;` -When an external module containing an export assignment is imported, the local alias introduced by the external import declaration takes on all meanings of the identifier named in the export assignment. +A module containing an export assignment can be imported using an import require declaration ([11.3.3](#11.3.3)), and the local alias introduced by the import require declaration then takes on all meanings of the identifier named in the export assignment. -It is an error for an external module to contain more than one export assignment. +A module containing an export assignment can also be imported using a regular import declaration ([11.3.2](#11.3.2)) provided the entity referenced in the export assignment is declared as a namespace or as a variable with a type annotation. Assume the following example resides in the file 'point.ts': @@ -5319,7 +5808,7 @@ class Point { } ``` -When 'point.ts' is imported in another external module, the import alias references the exported class and can be used both as a type and as a constructor function: +When 'point.ts' is imported in another module, the import alias references the exported class and can be used both as a type and as a constructor function: ```TypeScript import Pt = require("./point"); @@ -5330,11 +5819,11 @@ var p2 = Pt.origin; Note that there is no requirement that the import alias use the same name as the exported entity. -### 11.2.5 CommonJS Modules +### 11.3.6 CommonJS Modules -The CommonJS Modules definition specifies a methodology for writing JavaScript modules with implied privacy, the ability to import other modules, and the ability to explicitly export members. A CommonJS compliant system provides a 'require' function that can be used to synchronously load other external modules to obtain their singleton module instance, as well as an 'exports' variable to which a module can add properties to define its external API. +The [CommonJS Modules](http://www.commonjs.org/specs/modules/1.0/) definition specifies a methodology for writing JavaScript modules with implied privacy, the ability to import other modules, and the ability to explicitly export members. A CommonJS compliant system provides a 'require' function that can be used to synchronously load other modules to obtain their singleton module instance, as well as an 'exports' variable to which a module can add properties to define its external API. -The 'main' and 'log' example from section [11.2](#11.2) above generates the following JavaScript code when compiled for the CommonJS Modules pattern: +The 'main' and 'log' example from section [11.3](#11.3) above generates the following JavaScript code when compiled for the CommonJS Modules pattern: File main.js: @@ -5351,7 +5840,7 @@ exports.message = function(s) { } ``` -An external import declaration is represented in the generated JavaScript as a variable initialized by a call to the 'require' function provided by the module system host. A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or a local alias (section [10.3](#10.3)) that references the imported module, is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName* or *TypeQueryExpression*, nothing is emitted. +A module import declaration is represented in the generated JavaScript as a variable initialized by a call to the 'require' function provided by the module system host. A variable declaration and 'require' call is emitted for a particular imported module only if the imported module, or a local alias (section [10.3](#10.3)) that references the imported module, is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *NamespaceName* or *TypeQueryExpression*, nothing is emitted. An example: @@ -5392,9 +5881,9 @@ the emitted JavaScript would have no dependency on the 'geometry' module and wou var p = { x: 10, y: 20 }; ``` -### 11.2.6 AMD Modules +### 11.3.7 AMD Modules -The Asynchronous Module Definition (AMD) specification extends the CommonJS Modules specification with a pattern for authoring asynchronously loadable modules with associated dependencies. Using the AMD pattern, modules are emitted as calls to a global 'define' function taking an array of dependencies, specified as external module names, and a callback function containing the module body. The global 'define' function is provided by including an AMD compliant loader in the application. The loader arranges to asynchronously load the module's dependencies and, upon completion, calls the callback function passing resolved module instances as arguments in the order they were listed in the dependency array. +The [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) (AMD) specification extends the CommonJS Modules specification with a pattern for authoring asynchronously loadable modules with associated dependencies. Using the AMD pattern, modules are emitted as calls to a global 'define' function taking an array of dependencies, specified as module names, and a callback function containing the module body. The global 'define' function is provided by including an AMD compliant loader in the application. The loader arranges to asynchronously load the module's dependencies and, upon completion, calls the callback function passing resolved module instances as arguments in the order they were listed in the dependency array. The "main" and "log" example from above generates the following JavaScript code when compiled for the AMD pattern. @@ -5416,31 +5905,40 @@ define(["require", "exports"], function(require, exports) { } ``` -The special 'require' and 'exports' dependencies are always present. Additional entries are added to the dependencies array and the parameter list as required to represent imported external modules. Similar to the code generation for CommonJS Modules, a dependency entry is generated for a particular imported module only if the imported module is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *ModuleName*, no dependency is generated for that module. +The special 'require' and 'exports' dependencies are always present. Additional entries are added to the dependencies array and the parameter list as required to represent imported modules. Similar to the code generation for CommonJS Modules, a dependency entry is generated for a particular imported module only if the imported module is referenced as a *PrimaryExpression* somewhere in the body of the importing module. If an imported module is referenced only as a *NamespaceName*, no dependency is generated for that module.
#
12 Ambients -Ambient declarations are used to provide static typing over existing JavaScript code. Ambient declarations differ from regular declarations in that no JavaScript code is emitted for them. Instead of introducing new variables, functions, classes, enums, or modules, ambient declarations provide type information for entities that exist "ambiently" and are included in a program by external means, for example by referencing a JavaScript library in a <script/> tag. +Ambient declarations are used to provide static typing over existing JavaScript code. Ambient declarations differ from regular declarations in that no JavaScript code is emitted for them. Instead of introducing new variables, functions, classes, enums, or namespaces, ambient declarations provide type information for entities that exist "ambiently" and are included in a program by external means, for example by referencing a JavaScript library in a <script/> tag. ## 12.1 Ambient Declarations -Ambient declarations are written using the `declare` keyword and can declare variables, functions, classes, enums, internal modules, or external modules. +Ambient declarations are written using the `declare` keyword and can declare variables, functions, classes, enums, namespaces, or modules.   *AmbientDeclaration:*    `declare` *AmbientVariableDeclaration*    `declare` *AmbientFunctionDeclaration*    `declare` *AmbientClassDeclaration*    `declare` *AmbientEnumDeclaration* -   `declare` *AmbientModuleDeclaration* +   `declare` *AmbientNamespaceDeclaration* ### 12.1.1 Ambient Variable Declarations An ambient variable declaration introduces a variable in the containing declaration space.   *AmbientVariableDeclaration:* -   `var` *Identifier*  *TypeAnnotationopt* `;` +   `var` *AmbientBindingList* `;` +   `let` *AmbientBindingList* `;` +   `const` *AmbientBindingList* `;` + +  *AmbientBindingList:* +   *AmbientBinding* +   *AmbientBindingList* `,` *AmbientBinding* + +  *AmbientBinding:* +   *BindingIdentifier* *TypeAnnotationopt* An ambient variable declaration may optionally include a type annotation. If no type annotation is present, the variable is assumed to have type Any. @@ -5451,18 +5949,18 @@ An ambient variable declaration does not permit an initializer expression to be An ambient function declaration introduces a function in the containing declaration space.   *AmbientFunctionDeclaration:* -   `function` *Identifier* *CallSignature* `;` +   `function` *BindingIdentifier* *CallSignature* `;` -Ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical (section [3.10.2](#3.10.2)) or differ only in their return types. +Ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical (section [3.11.2](#3.11.2)) or differ only in their return types. Ambient function declarations cannot specify a function bodies and do not permit default parameter values. ### 12.1.3 Ambient Class Declarations -An ambient class declaration declares a class instance type and a constructor function in the containing module. +An ambient class declaration declares a class instance type and a constructor function in the containing declaration space.   *AmbientClassDeclaration:* -   `class` *Identifier* *TypeParametersopt* *ClassHeritage* `{` *AmbientClassBody* `}` +   `class` *BindingIdentifier* *TypeParametersopt* *ClassHeritage* `{` *AmbientClassBody* `}`   *AmbientClassBody:*    *AmbientClassBodyElementsopt* @@ -5497,55 +5995,44 @@ Ambient enum declarations differ from non-ambient enum declarations in two ways: Ambient enum declarations are otherwise processed in the same manner as non-ambient enum declarations. -### 12.1.5 Ambient Module Declarations +### 12.1.5 Ambient Namespace Declarations -An ambient module declaration declares an internal module. +An ambient namespace declaration declares a namespace. -  *AmbientModuleDeclaration:* -   `module` *IdentifierPath* `{` *AmbientModuleBody* `}` +  *AmbientNamespaceDeclaration:* +   `namespace` *IdentifierPath* `{` *AmbientNamespaceBody* `}` -  *AmbientModuleBody:* -   *AmbientModuleElementsopt* +  *AmbientNamespaceBody:* +   *AmbientNamespaceElementsopt* -  *AmbientModuleElements:* -   *AmbientModuleElement* -   *AmbientModuleElements* *AmbientModuleElement* +  *AmbientNamespaceElements:* +   *AmbientNamespaceElement* +   *AmbientNamespaceElements* *AmbientNamespaceElement* -  *AmbientModuleElement:* +  *AmbientNamespaceElement:*    `export`*opt* *AmbientVariableDeclaration* +   `export`*opt* *AmbientLexicalDeclaration*    `export`*opt* *AmbientFunctionDeclaration*    `export`*opt* *AmbientClassDeclaration*    `export`*opt* *InterfaceDeclaration*    `export`*opt* *AmbientEnumDeclaration* -   `export`*opt* *AmbientModuleDeclaration* -   `export`*opt* *ImportDeclaration* +   `export`*opt* *AmbientNamespaceDeclaration* +   `export`*opt* *ImportAliasDeclaration* -Except for *ImportDeclarations*, *AmbientModuleElements* always declare exported entities regardless of whether they include the optional `export` modifier. +Except for *ImportAliasDeclarations*, *AmbientNamespaceElements* always declare exported entities regardless of whether they include the optional `export` modifier. -## 12.2 Ambient External Module Declarations +## 12.2 Ambient Module Declarations -An *AmbientExternalModuleDeclaration* declares an external module. This type of declaration is permitted only at the top level in a source file that contributes to the global module (section [11.1](#11.1)). The *StringLiteral* must specify a top-level external module name. Relative external module names are not permitted. +An *AmbientModuleDeclaration* declares a module. This type of declaration is permitted only at the top level in a source file that contributes to the global namespace (section [11.1](#11.1)). The *StringLiteral* must specify a top-level module name. Relative module names are not permitted. -  *AmbientExternalModuleDeclaration:* -   `declare` `module` *StringLiteral* `{`  *AmbientExternalModuleBody* `}` +  *AmbientModuleDeclaration:* +   `declare` `module` *StringLiteral* `{`  *DeclarationModule* `}` -  *AmbientExternalModuleBody:* -   *AmbientExternalModuleElementsopt* +An *ImportRequireDeclaration* in an *AmbientModuleDeclaration* may reference other modules only through top-level module names. Relative module names are not permitted. -  *AmbientExternalModuleElements:* -   *AmbientExternalModuleElement* -   *AmbientExternalModuleElements* *AmbientExternalModuleElement* +If an ambient module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an `export` modifier. If an ambient module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional `export` modifier. -  *AmbientExternalModuleElement:* -   *AmbientModuleElement* -   *ExportAssignment* -   `export`*opt* *ExternalImportDeclaration* - -An *ExternalImportDeclaration* in an *AmbientExternalModuleDeclaration* may reference other external modules only through top-level external module names. Relative external module names are not permitted. - -If an ambient external module declaration includes an export assignment, it is an error for any of the declarations within the module to specify an `export` modifier. If an ambient external module declaration contains no export assignment, entities declared in the module are exported regardless of whether their declarations include the optional `export` modifier. - -Ambient external modules are "open-ended" and ambient external module declarations with the same string literal name contribute to a single external module. For example, the following two declarations of an external module 'io' might be located in separate source files. +Ambient modules are "open-ended" and ambient module declarations with the same string literal name contribute to a single module. For example, the following two declarations of a module 'io' might be located in separate source files. ```TypeScript declare module "io" { @@ -5570,7 +6057,7 @@ declare module "io" { # A Grammar -This appendix contains a summary of the grammar found in the main document. As described in section [2.1](#2.1), the TypeScript grammar is a superset of the grammar defined in the ECMAScript Language Specification (specifically, the ECMA-262 Standard, 5th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. +This appendix contains a summary of the grammar found in the main document. As described in section [2.1](#2.1), the TypeScript grammar is a superset of the grammar defined in the [ECMAScript Language Specification](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) (specifically, the ECMA-262 Standard, 6th Edition) and this appendix lists only productions that are new or modified from the ECMAScript grammar. ## A.1 Types @@ -5582,7 +6069,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *TypeParameterList* `,` *TypeParameter*   *TypeParameter:* -   *Identifier* *Constraintopt* +   *BindingIdentifier* *Constraintopt*   *Constraint:*    `extends` *Type* @@ -5598,13 +6085,17 @@ This appendix contains a summary of the grammar found in the main document. As d    *Type*   *Type:* -   *PrimaryOrUnionType* +   *UnionOrIntersectionOrPrimaryType*    *FunctionType*    *ConstructorType* -  *PrimaryOrUnionType:* -   *PrimaryType* -   *UnionType* +  *UnionOrIntersectionOrPrimaryType:* +   *UnionType* +   *IntersectionOrPrimaryType* + +  *IntersectionOrPrimaryType:* +   *IntersectionType* +   *PrimaryType*   *PrimaryType:*    *ParenthesizedType* @@ -5623,28 +6114,31 @@ This appendix contains a summary of the grammar found in the main document. As d    `number`    `boolean`    `string` +   `symbol`    `void`   *TypeReference:*    *TypeName* *[no LineTerminator here]* *TypeArgumentsopt*   *TypeName:* -   *Identifier* -   *ModuleName* `.` *Identifier* +   *IdentifierReference* +   *NamespaceName* `.` *IdentifierReference* -  *ModuleName:* -   *Identifier* -   *ModuleName* `.` *Identifier* +  *NamespaceName:* +   *IdentifierReference* +   *NamespaceName* `.` *IdentifierReference*   *ObjectType:*    `{` *TypeBodyopt* `}`   *TypeBody:* -   *TypeMemberList* `;`*opt* +   *TypeMemberList* `;`*opt* +   *TypeMemberList* `,`*opt*   *TypeMemberList:*    *TypeMember* -   *TypeMemberList* `;` *TypeMember* +   *TypeMemberList* `;` *TypeMember* +   *TypeMemberList* `,` *TypeMember*   *TypeMember:*    *PropertySignature* @@ -5667,7 +6161,10 @@ This appendix contains a summary of the grammar found in the main document. As d    *Type*   *UnionType:* -   *PrimaryOrUnionType* `|` *PrimaryType* +   *UnionOrIntersectionOrPrimaryType* `|` *IntersectionOrPrimaryType* + +  *IntersectionType:* +   *IntersectionOrPrimaryType* `&` *PrimaryType*   *FunctionType:*    *TypeParametersopt* `(` *ParameterListopt* `)` `=>` *Type* @@ -5679,7 +6176,7 @@ This appendix contains a summary of the grammar found in the main document. As d    `typeof` *TypeQueryExpression*   *TypeQueryExpression:* -   *Identifier* +   *IdentifierReference*    *TypeQueryExpression* `.` *IdentifierName*   *PropertySignature:* @@ -5690,6 +6187,9 @@ This appendix contains a summary of the grammar found in the main document. As d    *StringLiteral*    *NumericLiteral* +  *TypeAnnotation:* +   `:` *Type* +   *CallSignature:*    *TypeParametersopt* `(` *ParameterListopt* `)` *TypeAnnotationopt* @@ -5707,42 +6207,48 @@ This appendix contains a summary of the grammar found in the main document. As d    *RequiredParameterList* `,` *RequiredParameter*   *RequiredParameter:* -   *AccessibilityModifieropt* *Identifier* *TypeAnnotationopt* -   *Identifier* `:` *StringLiteral* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* *TypeAnnotationopt* +   *BindingIdentifier* `:` *StringLiteral*   *AccessibilityModifier:*    `public`    `private`    `protected` +  *BindingIdentifierOrPattern:* +   *BindingIdentifier* +   *BindingPattern* +   *OptionalParameterList:*    *OptionalParameter*    *OptionalParameterList* `,` *OptionalParameter*   *OptionalParameter:* -   *AccessibilityModifieropt* *Identifier* `?` *TypeAnnotationopt* -   *AccessibilityModifieropt* *Identifier* *TypeAnnotationopt* *Initialiser* -   *Identifier* `?` `:` *StringLiteral* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* `?` *TypeAnnotationopt* +   *AccessibilityModifieropt* *BindingIdentifierOrPattern* *TypeAnnotationopt* *Initializer* +   *BindingIdentifier* `?` `:` *StringLiteral*   *RestParameter:* -   `...` *Identifier* *TypeAnnotationopt* +   `...` *BindingIdentifier* *TypeAnnotationopt*   *ConstructSignature:*    `new` *TypeParametersopt* `(` *ParameterListopt* `)` *TypeAnnotationopt*   *IndexSignature:* -   `[` *Identifier* `:` `string` `]` *TypeAnnotation* -   `[` *Identifier* `:` `number` `]` *TypeAnnotation* +   `[` *BindingIdentifier* `:` `string` `]` *TypeAnnotation* +   `[` *BindingIdentifier* `:` `number` `]` *TypeAnnotation*   *MethodSignature:*    *PropertyName* `?`*opt* *CallSignature*   *TypeAliasDeclaration:* -   `type` *Identifier* `=` *Type* `;` +   `type` *BindingIdentifier* *TypeParametersopt* `=` *Type* `;` ## A.2 Expressions -  *PropertyAssignment:* *( Modified )* +  *PropertyDefinition:* *( Modified )* +   *IdentifierReference* +   *CoverInitializedName*    *PropertyName* `:` *AssignmentExpression*    *PropertyName* *CallSignature* `{` *FunctionBody* `}`    *GetAccessor* @@ -5752,36 +6258,13 @@ This appendix contains a summary of the grammar found in the main document. As d    `get` *PropertyName* `(` `)` *TypeAnnotationopt* `{` *FunctionBody* `}`   *SetAccessor:* -   `set` *PropertyName* `(` *Identifier* *TypeAnnotationopt* `)` `{` *FunctionBody* `}` - -  *ElementList:* *( Modified )* -   *Elisionopt* *AssignmentExpression* -   *Elisionopt* *SpreadElement* -   *ElementList* `,` *Elisionopt* *AssignmentExpression* -   *ElementList* `,` *Elisionopt* *SpreadElement* - -  *SpreadElement:* -   `...` *AssignmentExpression* - -  *CallExpression:* *( Modified )* -   … -   `super` `(` *ArgumentListopt* `)` -   `super` `.` *IdentifierName* +   `set` *PropertyName* `(` *BindingIdentifierOrPattern* *TypeAnnotationopt* `)` `{` *FunctionBody* `}`   *FunctionExpression:* *( Modified )* -   `function` *Identifieropt* *CallSignature* `{` *FunctionBody* `}` +   `function` *BindingIdentifieropt* *CallSignature* `{` *FunctionBody* `}` -  *AssignmentExpression:* *( Modified )* -   … -   *ArrowFunctionExpression* - -  *ArrowFunctionExpression:* -   *ArrowFormalParameters* `=>` *Block* -   *ArrowFormalParameters* `=>` *AssignmentExpression* - -  *ArrowFormalParameters:* -   *CallSignature* -   *Identifier* +  *ArrowFormalParameters:* *( Modified )* +   *CallSignature*   *Arguments:* *( Modified )*    *TypeArgumentsopt* `(` *ArgumentListopt* `)` @@ -5792,71 +6275,42 @@ This appendix contains a summary of the grammar found in the main document. As d ## A.3 Statements +  *Declaration:* *( Modified )* +   … +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* +   *VariableDeclaration:* *( Modified )*    *SimpleVariableDeclaration*    *DestructuringVariableDeclaration*   *SimpleVariableDeclaration:* -   *Identifier* *TypeAnnotationopt* *Initialiseropt* - -  *TypeAnnotation:* -   `:` *Type* +   *BindingIdentifier* *TypeAnnotationopt* *Initializeropt*   *DestructuringVariableDeclaration:* -   *BindingPattern* *TypeAnnotationopt* *Initialiser* +   *BindingPattern* *TypeAnnotationopt* *Initializer* -  *BindingPattern:* -   *ObjectBindingPattern* -   *ArrayBindingPattern* +  *LexicalBinding:* *( Modified )* +   *SimpleLexicalBinding* +   *DestructuringLexicalBinding* -  *ObjectBindingPattern:* -   `{` `}` -   `{` *BindingPropertyList* `,`*opt* `}` +  *SimpleLexicalBinding:* +   *BindingIdentifier* *TypeAnnotationopt* *Initializeropt* -  *BindingPropertyList:* -   *BindingProperty* -   *BindingPropertyList* `,` *BindingProperty* - -  *BindingProperty:* -   *Identifier* *Initialiseropt* -   *PropertyName* `:` *Identifier* *Initialiseropt* -   *PropertyName* `:` *BindingPattern* *Initialiseropt* - -  *ArrayBindingPattern:* -   `[` *Elisionopt* *BindingRestElementopt* `]` -   `[` *BindingElementList* `]` -   `[` *BindingElementList* `,` *Elisionopt* *BindingRestElementopt* `]` - -  *BindingElementList:* -   *Elisionopt* *BindingElement* -   *BindingElementList* `,` *Elisionopt* *BindingElement* - -  *BindingElement:* -   *Identifier* *Initialiseropt* -   *BindingPattern* *Initialiseropt* - -  *BindingRestElement:* -   `...` *Identifier* +  *DestructuringLexicalBinding:* +   *BindingPattern* *TypeAnnotationopt* *Initializeropt* ## A.4 Functions   *FunctionDeclaration:* *( Modified )* -   *FunctionOverloadsopt* *FunctionImplementation* - -  *FunctionOverloads:* -   *FunctionOverload* -   *FunctionOverloads* *FunctionOverload* - -  *FunctionOverload:* -   `function` *Identifier* *CallSignature* `;` - -  *FunctionImplementation:* -   `function` *Identifier* *CallSignature* `{` *FunctionBody* `}` +   `function` *BindingIdentifieropt* *CallSignature* `{` *FunctionBody* `}` +   `function` *BindingIdentifieropt* *CallSignature* `;` ## A.5 Interfaces   *InterfaceDeclaration:* -   `interface` *Identifier* *TypeParametersopt* *InterfaceExtendsClauseopt* *ObjectType* +   `interface` *BindingIdentifier* *TypeParametersopt* *InterfaceExtendsClauseopt* *ObjectType*   *InterfaceExtendsClause:*    `extends` *ClassOrInterfaceTypeList* @@ -5870,10 +6324,10 @@ This appendix contains a summary of the grammar found in the main document. As d ## A.6 Classes -  *ClassDeclaration:* -   `class` *Identifier* *TypeParametersopt* *ClassHeritage* `{` *ClassBody* `}` +  *ClassDeclaration:* *( Modified )* +   `class` *BindingIdentifieropt* *TypeParametersopt* *ClassHeritage* `{` *ClassBody* `}` -  *ClassHeritage:* +  *ClassHeritage:* *( Modified )*    *ClassExtendsClauseopt* *ImplementsClauseopt*   *ClassExtendsClause:* @@ -5885,52 +6339,27 @@ This appendix contains a summary of the grammar found in the main document. As d   *ImplementsClause:*    `implements` *ClassOrInterfaceTypeList* -  *ClassBody:* -   *ClassElementsopt* - -  *ClassElements:* -   *ClassElement* -   *ClassElements* *ClassElement* - -  *ClassElement:* +  *ClassElement:* *( Modified )*    *ConstructorDeclaration*    *PropertyMemberDeclaration*    *IndexMemberDeclaration*   *ConstructorDeclaration:* -   *ConstructorOverloadsopt* *ConstructorImplementation* - -  *ConstructorOverloads:* -   *ConstructorOverload* -   *ConstructorOverloads* *ConstructorOverload* - -  *ConstructorOverload:* +   *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `{` *FunctionBody* `}`    *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `;` -  *ConstructorImplementation:* -   *AccessibilityModifieropt* `constructor` `(` *ParameterListopt* `)` `{` *FunctionBody* `}` -   *PropertyMemberDeclaration:*    *MemberVariableDeclaration*    *MemberFunctionDeclaration*    *MemberAccessorDeclaration*   *MemberVariableDeclaration:* -   *AccessibilityModifieropt* `static`*opt* *PropertyName* *TypeAnnotationopt* *Initialiseropt* `;` +   *AccessibilityModifieropt* `static`*opt* *PropertyName* *TypeAnnotationopt* *Initializeropt* `;`   *MemberFunctionDeclaration:* -   *MemberFunctionOverloadsopt* *MemberFunctionImplementation* - -  *MemberFunctionOverloads*: -   *MemberFunctionOverload* -   *MemberFunctionOverloads* *MemberFunctionOverload* - -  *MemberFunctionOverload*: +   *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `{` *FunctionBody* `}`    *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `;` -  *MemberFunctionImplementation:* -   *AccessibilityModifieropt* `static`*opt* *PropertyName* *CallSignature* `{` *FunctionBody* `}` -   *MemberAccessorDeclaration:*    *AccessibilityModifieropt* `static`*opt* *GetAccessor*    *AccessibilityModifieropt* `static`*opt* *SetAccessor* @@ -5941,7 +6370,7 @@ This appendix contains a summary of the grammar found in the main document. As d ## A.7 Enums   *EnumDeclaration:* -   `const`*opt* `enum` *Identifier* `{` *EnumBodyopt* `}` +   `const`*opt* `enum` *BindingIdentifier* `{` *EnumBodyopt* `}`   *EnumBody:*    *EnumMemberList* `,`*opt* @@ -5957,84 +6386,185 @@ This appendix contains a summary of the grammar found in the main document. As d   *EnumValue:*    *AssignmentExpression* -## A.8 Internal Modules +## A.8 Namespaces -  *ModuleDeclaration:* -   `module` *IdentifierPath* `{` *ModuleBody* `}` +  *NamespaceDeclaration:* +   `namespace` *IdentifierPath* `{` *NamespaceBody* `}`   *IdentifierPath:* -   *Identifier* -   *IdentifierPath* `.` *Identifier* +   *BindingIdentifier* +   *IdentifierPath* `.` *BindingIdentifier* -  *ModuleBody:* -   *ModuleElementsopt* +  *NamespaceBody:* +   *NamespaceElementsopt* -  *ModuleElements:* -   *ModuleElement* -   *ModuleElements* *ModuleElement* +  *NamespaceElements:* +   *NamespaceElement* +   *NamespaceElements* *NamespaceElement* -  *ModuleElement:* +  *NamespaceElement:*    *Statement* -   `export`*opt* *VariableDeclaration* -   `export`*opt* *FunctionDeclaration* -   `export`*opt* *ClassDeclaration* -   `export`*opt* *InterfaceDeclaration* -   `export`*opt* *TypeAliasDeclaration* -   `export`*opt* *EnumDeclaration* -   `export`*opt* *ModuleDeclaration* -   `export`*opt* *ImportDeclaration* -   `export`*opt* *AmbientDeclaration* +   *LexicalDeclaration* +   *FunctionDeclaration* +   *GeneratorDeclaration* +   *ClassDeclaration* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* +   *NamespaceDeclaration +   AmbientDeclaration +   ImportAliasDeclaration +   ExportNamespaceElement* -  *ImportDeclaration:* -   `import` *Identifier* `=` *EntityName* `;` +  *ExportNamespaceElement:* +   `export` *VariableStatement* +   `export` *LexicalDeclaration* +   `export` *FunctionDeclaration* +   `export` *GeneratorDeclaration* +   `export` *ClassDeclaration* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *EnumDeclaration* +   `export` *NamespaceDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* + +  *ImportAliasDeclaration:* +   `import` *BindingIdentifier* `=` *EntityName* `;`   *EntityName:* -   *ModuleName* -   *ModuleName* `.` *Identifier* +   *NamespaceName* +   *NamespaceName* `.` *IdentifierReference* -## A.9 Source Files and External Modules +## A.9 Scripts and Modules   *SourceFile:*    *ImplementationSourceFile*    *DeclarationSourceFile*   *ImplementationSourceFile:* -   *ImplementationElementsopt* - -  *ImplementationElements:* -   *ImplementationElement* -   *ImplementationElements* *ImplementationElement* - -  *ImplementationElement:* -   *ModuleElement* -   *ExportAssignment* -   *AmbientExternalModuleDeclaration* -   `export`*opt* *ExternalImportDeclaration* +   *ImplementationScript* +   *ImplementationModule*   *DeclarationSourceFile:* -   *DeclarationElementsopt* +   *DeclarationScript* +   *DeclarationModule* -  *DeclarationElements:* +  *ImplementationScript:* +   *ImplementationScriptElementsopt* + +  *ImplementationScriptElements:* +   *ImplementationScriptElement* +   *ImplementationScriptElements* *ImplementationScriptElement* + +  *ImplementationScriptElement:* +   *ImplementationElement* +   *AmbientModuleDeclaration* + +  *ImplementationElement:* +   *Statement* +   *LexicalDeclaration* +   *FunctionDeclaration* +   *GeneratorDeclaration* +   *ClassDeclaration* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *EnumDeclaration* +   *NamespaceDeclaration* +   *AmbientDeclaration* +   *ImportAliasDeclaration* + +  *DeclarationScript:* +   *DeclarationScriptElementsopt* + +  *DeclarationScriptElements:* +   *DeclarationScriptElement* +   *DeclarationScriptElements* *DeclarationScriptElement* + +  *DeclarationScriptElement:*    *DeclarationElement* -   *DeclarationElements* *DeclarationElement* +   *AmbientModuleDeclaration*   *DeclarationElement:* -   *ExportAssignment* -   *AmbientExternalModuleDeclaration* -   `export`*opt* *InterfaceDeclaration* -   `export`*opt* *TypeAliasDeclaration* -   `export`*opt* *ImportDeclaration* -   `export`*opt* *AmbientDeclaration* -   `export`*opt* *ExternalImportDeclaration* +   *InterfaceDeclaration* +   *TypeAliasDeclaration* +   *NamespaceDeclaration* +   *AmbientDeclaration* +   *ImportAliasDeclaration* -  *ExternalImportDeclaration:* -   `import` *Identifier* `=` *ExternalModuleReference* `;` +  *ImplementationModule:* +   *ImplementationModuleElementsopt* -  *ExternalModuleReference:* -   `require` `(` *StringLiteral* `)` +  *ImplementationModuleElements:* +   *ImplementationModuleElement* +   *ImplementationModuleElements* *ImplementationModuleElement* + +  *ImplementationModuleElement:* +   *ImplementationElement* +   *ImportDeclaration* +   *ImportAliasDeclaration* +   *ImportRequireDeclaration* +   *ExportImplementationElement* +   *ExportDefaultImplementationElement* +   *ExportListDeclaration* +   *ExportAssignment* + +  *DeclarationModule:* +   *DeclarationModuleElementsopt* + +  *DeclarationModuleElements:* +   *DeclarationModuleElement* +   *DeclarationModuleElements* *DeclarationModuleElement* + +  *DeclarationModuleElement:* +   *DeclarationElement* +   *ImportDeclaration* +   *ImportAliasDeclaration* +   *ExportDeclarationElement* +   *ExportDefaultDeclarationElement* +   *ExportListDeclaration* +   *ExportAssignment* + +  *ImportRequireDeclaration:* +   `import` *BindingIdentifier* `=` `require` `(` *StringLiteral* `)` `;` + +  *ExportImplementationElement:* +   `export` *VariableStatement* +   `export` *LexicalDeclaration* +   `export` *FunctionDeclaration* +   `export` *GeneratorDeclaration* +   `export` *ClassDeclaration* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *EnumDeclaration* +   `export` *NamespaceDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* + +  *ExportDeclarationElement:* +   `export` *InterfaceDeclaration* +   `export` *TypeAliasDeclaration* +   `export` *AmbientDeclaration* +   `export` *ImportAliasDeclaration* + +  *ExportDefaultImplementationElement:* +   `export` `default` *FunctionDeclaration* +   `export` `default` *GeneratorDeclaration* +   `export` `default` *ClassDeclaration* +   `export` `default` *AssignmentExpression* `;` + +  *ExportDefaultDeclarationElement:* +   `export` `default` *AmbientFunctionDeclaration* +   `export` `default` *AmbientClassDeclaration* +   `export` `default` *IdentifierReference* `;` + +  *ExportListDeclaration:* +   `export` `*` *FromClause* `;` +   `export` *ExportClause* *FromClause* `;` +   `export` *ExportClause* `;`   *ExportAssignment:* -   `export` `=` *Identifier* `;` +   `export` `=` *IdentifierReference* `;` ## A.10 Ambients @@ -6043,16 +6573,25 @@ This appendix contains a summary of the grammar found in the main document. As d    `declare` *AmbientFunctionDeclaration*    `declare` *AmbientClassDeclaration*    `declare` *AmbientEnumDeclaration* -   `declare` *AmbientModuleDeclaration* +   `declare` *AmbientNamespaceDeclaration*   *AmbientVariableDeclaration:* -   `var` *Identifier*  *TypeAnnotationopt* `;` +   `var` *AmbientBindingList* `;` +   `let` *AmbientBindingList* `;` +   `const` *AmbientBindingList* `;` + +  *AmbientBindingList:* +   *AmbientBinding* +   *AmbientBindingList* `,` *AmbientBinding* + +  *AmbientBinding:* +   *BindingIdentifier* *TypeAnnotationopt*   *AmbientFunctionDeclaration:* -   `function` *Identifier* *CallSignature* `;` +   `function` *BindingIdentifier* *CallSignature* `;`   *AmbientClassDeclaration:* -   `class` *Identifier* *TypeParametersopt* *ClassHeritage* `{` *AmbientClassBody* `}` +   `class` *BindingIdentifier* *TypeParametersopt* *ClassHeritage* `{` *AmbientClassBody* `}`   *AmbientClassBody:*    *AmbientClassBodyElementsopt* @@ -6076,37 +6615,26 @@ This appendix contains a summary of the grammar found in the main document. As d   *AmbientEnumDeclaration:*    *EnumDeclaration* -  *AmbientModuleDeclaration:* -   `module` *IdentifierPath* `{` *AmbientModuleBody* `}` +  *AmbientNamespaceDeclaration:* +   `namespace` *IdentifierPath* `{` *AmbientNamespaceBody* `}` -  *AmbientModuleBody:* -   *AmbientModuleElementsopt* +  *AmbientNamespaceBody:* +   *AmbientNamespaceElementsopt* -  *AmbientModuleElements:* -   *AmbientModuleElement* -   *AmbientModuleElements* *AmbientModuleElement* +  *AmbientNamespaceElements:* +   *AmbientNamespaceElement* +   *AmbientNamespaceElements* *AmbientNamespaceElement* -  *AmbientModuleElement:* +  *AmbientNamespaceElement:*    `export`*opt* *AmbientVariableDeclaration* +   `export`*opt* *AmbientLexicalDeclaration*    `export`*opt* *AmbientFunctionDeclaration*    `export`*opt* *AmbientClassDeclaration*    `export`*opt* *InterfaceDeclaration*    `export`*opt* *AmbientEnumDeclaration* -   `export`*opt* *AmbientModuleDeclaration* -   `export`*opt* *ImportDeclaration* +   `export`*opt* *AmbientNamespaceDeclaration* +   `export`*opt* *ImportAliasDeclaration* -  *AmbientExternalModuleDeclaration:* -   `declare` `module` *StringLiteral* `{`  *AmbientExternalModuleBody* `}` - -  *AmbientExternalModuleBody:* -   *AmbientExternalModuleElementsopt* - -  *AmbientExternalModuleElements:* -   *AmbientExternalModuleElement* -   *AmbientExternalModuleElements* *AmbientExternalModuleElement* - -  *AmbientExternalModuleElement:* -   *AmbientModuleElement* -   *ExportAssignment* -   `export`*opt* *ExternalImportDeclaration* +  *AmbientModuleDeclaration:* +   `declare` `module` *StringLiteral* `{`  *DeclarationModule* `}` diff --git a/bin/lib.webworker.d.ts b/lib/lib.core.d.ts similarity index 60% rename from bin/lib.webworker.d.ts rename to lib/lib.core.d.ts index d9e8a2ab333..b588c9fdb77 100644 --- a/bin/lib.webworker.d.ts +++ b/lib/lib.core.d.ts @@ -13,12 +13,1197 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -/// +/// ///////////////////////////// -/// IE10 ECMAScript Extensions +/// 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: T): T; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: T): T; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: T): T; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare 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 that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): string; + + [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; + + /** Returns the primitive value of the specified object. */ + valueOf(): number; +} + +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. + * @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 regExp 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: string | number): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: string | number): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare 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): arg is Array; + prototype: Array; +} + +declare var Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + /** * Represents a raw buffer of binary data, which is used to store data for the * different typed arrays. ArrayBuffers cannot be read from or written to directly, @@ -70,14 +1255,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat32(byteOffset: number, littleEndian: boolean): number; + getFloat32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat64(byteOffset: number, littleEndian: boolean): number; + getFloat64(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int8 value at the specified byte offset from the start of the view. There is @@ -91,13 +1276,13 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt16(byteOffset: number, littleEndian: boolean): number; + getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt32(byteOffset: number, littleEndian: boolean): number; + getInt32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint8 value at the specified byte offset from the start of the view. There is @@ -111,14 +1296,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint16(byteOffset: number, littleEndian: boolean): number; + getUint16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint32(byteOffset: number, littleEndian: boolean): number; + getUint32(byteOffset: number, littleEndian?: boolean): number; /** * Stores an Float32 value at the specified byte offset from the start of the view. @@ -127,7 +1312,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Float64 value at the specified byte offset from the start of the view. @@ -136,7 +1321,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int8 value at the specified byte offset from the start of the view. @@ -152,7 +1337,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int32 value at the specified byte offset from the start of the view. @@ -161,7 +1346,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint8 value at the specified byte offset from the start of the view. @@ -177,7 +1362,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint32 value at the specified byte offset from the start of the view. @@ -186,7 +1371,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } interface DataViewConstructor { @@ -393,7 +1578,7 @@ interface Int8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -442,8 +1627,7 @@ interface Int8Array { interface Int8ArrayConstructor { prototype: Int8Array; new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; + new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** @@ -456,6 +1640,15 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + } declare var Int8Array: Int8ArrayConstructor; @@ -658,7 +1851,7 @@ interface Uint8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -708,8 +1901,7 @@ interface Uint8Array { interface Uint8ArrayConstructor { prototype: Uint8Array; new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; + new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** @@ -722,9 +1914,291 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + } declare var Uint8Array: Uint8ArrayConstructor; +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -924,7 +2398,7 @@ interface Int16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -974,8 +2448,7 @@ interface Int16Array { interface Int16ArrayConstructor { prototype: Int16Array; new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; + new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** @@ -988,6 +2461,15 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + } declare var Int16Array: Int16ArrayConstructor; @@ -1190,7 +2672,7 @@ interface Uint16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1240,8 +2722,7 @@ interface Uint16Array { interface Uint16ArrayConstructor { prototype: Uint16Array; new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; + new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** @@ -1254,6 +2735,15 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + } declare var Uint16Array: Uint16ArrayConstructor; /** @@ -1455,7 +2945,7 @@ interface Int32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1505,8 +2995,7 @@ interface Int32Array { interface Int32ArrayConstructor { prototype: Int32Array; new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; + new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** @@ -1519,6 +3008,14 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; @@ -1721,7 +3218,7 @@ interface Uint32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1771,8 +3268,7 @@ interface Uint32Array { interface Uint32ArrayConstructor { prototype: Uint32Array; new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; + new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** @@ -1785,6 +3281,14 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; @@ -1987,7 +3491,7 @@ interface Float32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2037,8 +3541,7 @@ interface Float32Array { interface Float32ArrayConstructor { prototype: Float32Array; new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; + new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** @@ -2051,6 +3554,15 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + } declare var Float32Array: Float32ArrayConstructor; @@ -2253,7 +3765,7 @@ interface Float64Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float64Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2303,8 +3815,7 @@ interface Float64Array { interface Float64ArrayConstructor { prototype: Float64Array; new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; + new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** @@ -2317,1041 +3828,13 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// -/// ECMAScript Internationalization API -///////////////////////////// - -declare module Intl { - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - minimumintegerDigits?: number; - minimumFractionDigits?: number; - maximumFractionDigits?: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): NumberFormat; - new (locale?: string, options?: NumberFormatOptions): NumberFormat; - (locales?: string[], options?: NumberFormatOptions): NumberFormat; - (locale?: string, options?: NumberFormatOptions): NumberFormat; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12?: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date?: Date | number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; - new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; - (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; - (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { + /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + * 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. */ - 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; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } - -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 Worker APIs -///////////////////////////// - -interface EventListener { - (evt: Event): void; -} - -interface Blob { - size: number; - type: string; - msClose(): void; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; -} - -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): Blob; -} - -interface CloseEvent extends Event { - code: number; - reason: string; - wasClean: boolean; - initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; -} - -declare var CloseEvent: { - prototype: CloseEvent; - new(): CloseEvent; -} - -interface Console { - assert(test?: boolean, message?: string, ...optionalParams: any[]): void; - clear(): void; - count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; - dir(value?: any, ...optionalParams: any[]): void; - dirxml(value: any): void; - error(message?: any, ...optionalParams: any[]): void; - group(groupTitle?: string): void; - groupCollapsed(groupTitle?: string): void; - groupEnd(): void; - info(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: any): boolean; - profile(reportName?: string): void; - profileEnd(): void; - select(element: any): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(): void; - warn(message?: any, ...optionalParams: any[]): void; -} - -declare var Console: { - prototype: Console; - new(): Console; -} - -interface DOMError { - name: string; - toString(): string; -} - -declare var DOMError: { - prototype: DOMError; - new(): DOMError; -} - -interface DOMException { - code: number; - message: string; - name: string; - toString(): string; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; -} - -declare var DOMException: { - prototype: DOMException; - new(): DOMException; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; -} - -interface DOMStringList { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} - -declare var DOMStringList: { - prototype: DOMStringList; - new(): DOMStringList; -} - -interface ErrorEvent extends Event { - colno: number; - error: any; - filename: string; - lineno: number; - message: string; - initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; -} - -declare var ErrorEvent: { - prototype: ErrorEvent; - new(): ErrorEvent; -} - -interface Event { - bubbles: boolean; - cancelBubble: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - returnValue: boolean; - srcElement: any; - target: EventTarget; - timeStamp: number; - type: string; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - preventDefault(): void; - stopImmediatePropagation(): void; - stopPropagation(): void; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; -} - -declare var Event: { - prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; -} - -interface EventTarget { - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var EventTarget: { - prototype: EventTarget; - new(): EventTarget; -} - -interface File extends Blob { - lastModifiedDate: any; - name: string; -} - -declare var File: { - prototype: File; - new(): File; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} - -declare var FileList: { - prototype: FileList; - new(): FileList; -} - -interface FileReader extends EventTarget, MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsBinaryString(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var FileReader: { - prototype: FileReader; - new(): FileReader; -} - -interface IDBCursor { - direction: string; - key: any; - primaryKey: any; - source: any; - advance(count: number): void; - continue(key?: any): void; - delete(): IDBRequest; - update(value: any): IDBRequest; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; -} - -declare var IDBCursor: { - prototype: IDBCursor; - new(): IDBCursor; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; -} - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} - -declare var IDBCursorWithValue: { - prototype: IDBCursorWithValue; - new(): IDBCursorWithValue; -} - -interface IDBDatabase extends EventTarget { - name: string; - objectStoreNames: DOMStringList; - onabort: (ev: Event) => any; - onerror: (ev: Event) => any; - version: string; - close(): void; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; - deleteObjectStore(name: string): void; - transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var IDBDatabase: { - prototype: IDBDatabase; - new(): IDBDatabase; -} - -interface IDBFactory { - cmp(first: any, second: any): number; - deleteDatabase(name: string): IDBOpenDBRequest; - open(name: string, version?: number): IDBOpenDBRequest; -} - -declare var IDBFactory: { - prototype: IDBFactory; - new(): IDBFactory; -} - -interface IDBIndex { - keyPath: string; - name: string; - objectStore: IDBObjectStore; - unique: boolean; - count(key?: any): IDBRequest; - get(key: any): IDBRequest; - getKey(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} - -declare var IDBIndex: { - prototype: IDBIndex; - new(): IDBIndex; -} - -interface IDBKeyRange { - lower: any; - lowerOpen: boolean; - upper: any; - upperOpen: boolean; -} - -declare var IDBKeyRange: { - prototype: IDBKeyRange; - new(): IDBKeyRange; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} - -interface IDBObjectStore { - indexNames: DOMStringList; - keyPath: string; - name: string; - transaction: IDBTransaction; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - count(key?: any): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - delete(key: any): IDBRequest; - deleteIndex(indexName: string): void; - get(key: any): IDBRequest; - index(name: string): IDBIndex; - openCursor(range?: any, direction?: string): IDBRequest; - put(value: any, key?: any): IDBRequest; -} - -declare var IDBObjectStore: { - prototype: IDBObjectStore; - new(): IDBObjectStore; -} - -interface IDBOpenDBRequest extends IDBRequest { - onblocked: (ev: Event) => any; - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var IDBOpenDBRequest: { - prototype: IDBOpenDBRequest; - new(): IDBOpenDBRequest; -} - -interface IDBRequest extends EventTarget { - error: DOMError; - onerror: (ev: Event) => any; - onsuccess: (ev: Event) => any; - readyState: string; - result: any; - source: any; - transaction: IDBTransaction; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var IDBRequest: { - prototype: IDBRequest; - new(): IDBRequest; -} - -interface IDBTransaction extends EventTarget { - db: IDBDatabase; - error: DOMError; - mode: string; - onabort: (ev: Event) => any; - oncomplete: (ev: Event) => any; - onerror: (ev: Event) => any; - abort(): void; - objectStore(name: string): IDBObjectStore; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var IDBTransaction: { - prototype: IDBTransaction; - new(): IDBTransaction; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; -} - -interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; -} - -declare var IDBVersionChangeEvent: { - prototype: IDBVersionChangeEvent; - new(): IDBVersionChangeEvent; -} - -interface ImageData { - data: number[]; - height: number; - width: number; -} - -declare var ImageData: { - prototype: ImageData; - new(): ImageData; -} - -interface MSApp { - clearTemporaryWebDataAsync(): MSAppAsyncOperation; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createDataPackage(object: any): any; - createDataPackageFromSelection(): any; - createFileFromStorageFile(storageFile: any): File; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; - getViewId(view: any): any; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - pageHandlesAllApplicationActivations(enabled: boolean): void; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - terminateApp(exceptionObject: any): void; - CURRENT: string; - HIGH: string; - IDLE: string; - NORMAL: string; -} -declare var MSApp: MSApp; - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} - -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new(): MSBlobBuilder; -} - -interface MSStream { - type: string; - msClose(): void; - msDetachStream(): any; -} - -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MSStreamReader extends EventTarget, MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBinaryString(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSStreamReader: { - prototype: MSStreamReader; - new(): MSStreamReader; -} - -interface MessageChannel { - port1: MessagePort; - port2: MessagePort; -} - -declare var MessageChannel: { - prototype: MessageChannel; - new(): MessageChannel; -} - -interface MessageEvent extends Event { - data: any; - origin: string; - ports: any; - source: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: any): void; -} - -declare var MessageEvent: { - prototype: MessageEvent; - new(): MessageEvent; -} - -interface MessagePort extends EventTarget { - onmessage: (ev: MessageEvent) => any; - close(): void; - postMessage(message?: any, ports?: any): void; - start(): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MessagePort: { - prototype: MessagePort; - new(): MessagePort; -} - -interface ProgressEvent extends Event { - lengthComputable: boolean; - loaded: number; - total: number; - initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; -} - -declare var ProgressEvent: { - prototype: ProgressEvent; - new(): ProgressEvent; -} - -interface WebSocket extends EventTarget { - binaryType: string; - bufferedAmount: number; - extensions: string; - onclose: (ev: CloseEvent) => any; - onerror: (ev: Event) => any; - onmessage: (ev: MessageEvent) => any; - onopen: (ev: Event) => any; - protocol: string; - readyState: number; - url: string; - close(code?: number, reason?: string): void; - send(data: any): void; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var WebSocket: { - prototype: WebSocket; - new(url: string, protocols?: string | string[]): WebSocket; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; -} - -interface Worker extends EventTarget, AbstractWorker { - onmessage: (ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; - terminate(): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var Worker: { - prototype: Worker; - new(stringUrl: string): Worker; -} - -interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - msCaching: string; - onreadystatechange: (ev: ProgressEvent) => any; - readyState: number; - response: any; - responseBody: any; - responseText: string; - responseType: string; - responseXML: any; - status: number; - statusText: string; - timeout: number; - upload: XMLHttpRequestUpload; - withCredentials: boolean; - abort(): void; - getAllResponseHeaders(): string; - getResponseHeader(header: string): string; - msCachingEnabled(): boolean; - open(method: string, url: string, async?: boolean, user?: string, password?: string): void; - overrideMimeType(mime: string): void; - send(data?: string): void; - send(data?: any): void; - setRequestHeader(header: string, value: string): void; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new(): XMLHttpRequest; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; - create(): XMLHttpRequest; -} - -interface AbstractWorker { - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -interface MSBaseReader { - onabort: (ev: Event) => any; - onerror: (ev: Event) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - readyState: number; - result: any; - abort(): void; - DONE: number; - EMPTY: number; - LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -interface NavigatorID { - appName: string; - appVersion: string; - platform: string; - product: string; - productSub: string; - userAgent: string; - vendor: string; - vendorSub: string; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface WindowBase64 { - atob(encodedString: string): string; - btoa(rawString: string): string; -} - -interface WindowConsole { - console: Console; -} - -interface XMLHttpRequestEventTarget { - onabort: (ev: Event) => any; - onerror: (ev: Event) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -interface FileReaderSync { - readAsArrayBuffer(blob: Blob): any; - readAsBinaryString(blob: Blob): void; - readAsDataURL(blob: Blob): string; - readAsText(blob: Blob, encoding?: string): string; -} - -declare var FileReaderSync: { - prototype: FileReaderSync; - new(): FileReaderSync; -} - -interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { - location: WorkerLocation; - onerror: (ev: Event) => any; - self: WorkerGlobalScope; - close(): void; - msWriteProfilerMark(profilerMarkName: string): void; - toString(): string; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var WorkerGlobalScope: { - prototype: WorkerGlobalScope; - new(): WorkerGlobalScope; -} - -interface WorkerLocation { - hash: string; - host: string; - hostname: string; - href: string; - pathname: string; - port: string; - protocol: string; - search: string; - toString(): string; -} - -declare var WorkerLocation: { - prototype: WorkerLocation; - new(): WorkerLocation; -} - -interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var WorkerNavigator: { - prototype: WorkerNavigator; - new(): WorkerNavigator; -} - -interface DedicatedWorkerGlobalScope { - onmessage: (ev: MessageEvent) => any; - postMessage(data: any): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -interface WorkerUtils extends Object, WindowBase64 { - indexedDB: IDBFactory; - msIndexedDB: IDBFactory; - navigator: WorkerNavigator; - clearImmediate(handle: number): void; - clearInterval(handle: number): void; - clearTimeout(handle: number): void; - importScripts(...urls: string[]): void; - setImmediate(handler: any, ...args: any[]): number; - setInterval(handler: any, timeout?: any, ...args: any[]): number; - setTimeout(handler: any, timeout?: any, ...args: any[]): number; -} - - -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface BlobPropertyBag { - type?: string; - endings?: string; -} - -interface EventListenerObject { - handleEvent(evt: Event): void; -} - -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - -interface ErrorEventHandler { - (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; -} -interface PositionCallback { - (position: Position): void; -} -interface PositionErrorCallback { - (error: PositionError): void; -} -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} -interface MSLaunchUriCallback { - (): void; -} -interface FrameRequestCallback { - (time: number): void; -} -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; -} -interface DecodeSuccessCallback { - (decodedData: AudioBuffer): void; -} -interface DecodeErrorCallback { - (): void; -} -interface FunctionStringCallback { - (data: string): void; -} -declare var location: WorkerLocation; -declare var onerror: (ev: Event) => any; -declare var self: WorkerGlobalScope; -declare function close(): void; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function toString(): string; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -declare var indexedDB: IDBFactory; -declare var msIndexedDB: IDBFactory; -declare var navigator: WorkerNavigator; -declare function clearImmediate(handle: number): void; -declare function clearInterval(handle: number): void; -declare function clearTimeout(handle: number): void; -declare function importScripts(...urls: string[]): void; -declare function setImmediate(handler: any, ...args: any[]): number; -declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; -declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; -declare function atob(encodedString: string): string; -declare function btoa(rawString: string): string; -declare var onmessage: (ev: MessageEvent) => any; -declare function postMessage(data: any): void; -declare var console: Console; -declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare var Float64Array: Float64ArrayConstructor; diff --git a/bin/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts similarity index 90% rename from bin/lib.core.es6.d.ts rename to lib/lib.core.es6.d.ts index 48d02ec1465..fd115497f8a 100644 --- a/bin/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1369,16 +4010,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4091,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4229,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4260,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4506,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4604,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4697,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4733,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4765,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4801,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4837,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4869,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4901,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4933,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4965,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +4997,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5023,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,20 +5126,3 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} \ No newline at end of file diff --git a/bin/lib.d.ts b/lib/lib.d.ts similarity index 94% rename from bin/lib.d.ts rename to lib/lib.d.ts index 430d8279de4..c55970d9aca 100644 --- a/bin/lib.d.ts +++ b/lib/lib.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,11 +1196,13 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1253,14 +1255,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat32(byteOffset: number, littleEndian: boolean): number; + getFloat32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat64(byteOffset: number, littleEndian: boolean): number; + getFloat64(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int8 value at the specified byte offset from the start of the view. There is @@ -1274,13 +1276,13 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt16(byteOffset: number, littleEndian: boolean): number; + getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt32(byteOffset: number, littleEndian: boolean): number; + getInt32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint8 value at the specified byte offset from the start of the view. There is @@ -1294,14 +1296,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint16(byteOffset: number, littleEndian: boolean): number; + getUint16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint32(byteOffset: number, littleEndian: boolean): number; + getUint32(byteOffset: number, littleEndian?: boolean): number; /** * Stores an Float32 value at the specified byte offset from the start of the view. @@ -1310,7 +1312,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Float64 value at the specified byte offset from the start of the view. @@ -1319,7 +1321,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int8 value at the specified byte offset from the start of the view. @@ -1335,7 +1337,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int32 value at the specified byte offset from the start of the view. @@ -1344,7 +1346,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint8 value at the specified byte offset from the start of the view. @@ -1360,7 +1362,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint32 value at the specified byte offset from the start of the view. @@ -1369,7 +1371,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } interface DataViewConstructor { @@ -1576,7 +1578,7 @@ interface Int8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1625,8 +1627,7 @@ interface Int8Array { interface Int8ArrayConstructor { prototype: Int8Array; new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; + new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** @@ -1639,6 +1640,15 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + } declare var Int8Array: Int8ArrayConstructor; @@ -1841,7 +1851,7 @@ interface Uint8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1891,8 +1901,7 @@ interface Uint8Array { interface Uint8ArrayConstructor { prototype: Uint8Array; new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; + new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** @@ -1905,9 +1914,291 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + } declare var Uint8Array: Uint8ArrayConstructor; +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -2107,7 +2398,7 @@ interface Int16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2157,8 +2448,7 @@ interface Int16Array { interface Int16ArrayConstructor { prototype: Int16Array; new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; + new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** @@ -2171,6 +2461,15 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + } declare var Int16Array: Int16ArrayConstructor; @@ -2373,7 +2672,7 @@ interface Uint16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2423,8 +2722,7 @@ interface Uint16Array { interface Uint16ArrayConstructor { prototype: Uint16Array; new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; + new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** @@ -2437,6 +2735,15 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + } declare var Uint16Array: Uint16ArrayConstructor; /** @@ -2638,7 +2945,7 @@ interface Int32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2688,8 +2995,7 @@ interface Int32Array { interface Int32ArrayConstructor { prototype: Int32Array; new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; + new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** @@ -2702,6 +3008,14 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; @@ -2904,7 +3218,7 @@ interface Uint32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2954,8 +3268,7 @@ interface Uint32Array { interface Uint32ArrayConstructor { prototype: Uint32Array; new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; + new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** @@ -2968,6 +3281,14 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; @@ -3170,7 +3491,7 @@ interface Float32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3220,8 +3541,7 @@ interface Float32Array { interface Float32ArrayConstructor { prototype: Float32Array; new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; + new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** @@ -3234,6 +3554,15 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + } declare var Float32Array: Float32ArrayConstructor; @@ -3436,7 +3765,7 @@ interface Float64Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float64Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3486,8 +3815,7 @@ interface Float64Array { interface Float64ArrayConstructor { prototype: Float64Array; new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; + new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** @@ -3500,8 +3828,17 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// +declare var Float64Array: Float64ArrayConstructor; +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -6135,7 +6472,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -6592,6 +6929,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -6706,7 +7044,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -7579,7 +7917,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -10541,7 +10878,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10662,7 +10999,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10692,11 +11029,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -11379,7 +11719,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -12121,7 +12461,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -15638,7 +15978,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -15845,7 +16185,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16115,7 +16455,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16271,7 +16611,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16293,12 +16633,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16453,7 +16813,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; diff --git a/bin/lib.dom.d.ts b/lib/lib.dom.d.ts similarity index 80% rename from bin/lib.dom.d.ts rename to lib/lib.dom.d.ts index 5ec268b2fd5..54461afef40 100644 --- a/bin/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -14,2311 +14,7 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} - -interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; -} - -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -4952,7 +2648,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -5409,6 +3105,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -5523,7 +3220,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -6396,7 +4093,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -9358,7 +7054,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9479,7 +7175,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9509,11 +7205,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -10196,7 +7895,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -10938,7 +8637,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -14455,7 +12154,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -14662,7 +12361,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -14932,7 +12631,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15088,7 +12787,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15110,12 +12809,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -15270,7 +12989,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; diff --git a/bin/lib.es6.d.ts b/lib/lib.es6.d.ts similarity index 95% rename from bin/lib.es6.d.ts rename to lib/lib.es6.d.ts index 6c06cc08dc7..de051a44edd 100644 --- a/bin/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer Array that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer: any[], space: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1369,16 +4010,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4091,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4229,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4260,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4506,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4604,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4697,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4733,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4765,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4801,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4837,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4869,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4901,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4933,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4965,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +4997,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5023,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,23 +5126,7 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -}///////////////////////////// +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -7507,7 +7760,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -7964,6 +8217,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -8078,7 +8332,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -8951,7 +9205,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -11913,7 +12166,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12034,7 +12287,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12064,11 +12317,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -12751,7 +13007,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -13493,7 +13749,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -17010,7 +17266,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -17217,7 +17473,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17487,7 +17743,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17643,7 +17899,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17665,12 +17921,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -17825,7 +18101,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; @@ -18011,6 +18287,7 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator } + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/lib.scriptHost.d.ts b/lib/lib.scriptHost.d.ts similarity index 100% rename from bin/lib.scriptHost.d.ts rename to lib/lib.scriptHost.d.ts diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts new file mode 100644 index 00000000000..0f3e85da9f1 --- /dev/null +++ b/lib/lib.webworker.d.ts @@ -0,0 +1,1174 @@ +/*! ***************************************************************************** +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 Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + minimumintegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): NumberFormat; + new (locale?: string, options?: NumberFormatOptions): NumberFormat; + (locales?: string[], options?: NumberFormatOptions): NumberFormat; + (locale?: string, options?: NumberFormatOptions): NumberFormat; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12?: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date?: Date | number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + + /** + * Converts a number to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + /** + * Converts a date 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 Worker APIs +///////////////////////////// + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + +interface EventListener { + (evt: Event): void; +} + +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): any; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface Blob { + size: number; + type: string; + msClose(): void; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; +} + +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface CloseEvent extends Event { + code: number; + reason: string; + wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(): CloseEvent; +} + +interface Console { + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + clear(): void; + count(countTitle?: string): void; + debug(message?: string, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + group(groupTitle?: string): void; + groupCollapsed(groupTitle?: string): void; + groupEnd(): void; + info(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: any): boolean; + profile(reportName?: string): void; + profileEnd(): void; + select(element: any): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + warn(message?: any, ...optionalParams: any[]): void; +} + +declare var Console: { + prototype: Console; + new(): Console; +} + +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface DOMError { + name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + code: number; + message: string; + name: string; + toString(): string; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface ErrorEvent extends Event { + colno: number; + error: any; + filename: string; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(): ErrorEvent; +} + +interface Event { + bubbles: boolean; + cancelBubble: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + returnValue: boolean; + srcElement: any; + target: EventTarget; + timeStamp: number; + type: string; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(type: string, eventInitDict?: EventInit): Event; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface IDBCursor { + direction: string; + key: any; + primaryKey: any; + source: any; + advance(count: number): void; + continue(key?: any): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabase extends EventTarget { + name: string; + objectStoreNames: DOMStringList; + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + version: string; + close(): void; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBDatabase: { + prototype: IDBDatabase; + new(): IDBDatabase; +} + +interface IDBFactory { + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; + open(name: string, version?: number): IDBOpenDBRequest; +} + +declare var IDBFactory: { + prototype: IDBFactory; + new(): IDBFactory; +} + +interface IDBIndex { + keyPath: string; + name: string; + objectStore: IDBObjectStore; + unique: boolean; + count(key?: any): IDBRequest; + get(key: any): IDBRequest; + getKey(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + lower: any; + lowerOpen: boolean; + upper: any; + upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + keyPath: string; + name: string; + transaction: IDBTransaction; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + count(key?: any): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + delete(key: any): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: any, direction?: string): IDBRequest; + put(value: any, key?: any): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (ev: Event) => any; + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequest extends EventTarget { + error: DOMError; + onerror: (ev: Event) => any; + onsuccess: (ev: Event) => any; + readyState: string; + result: any; + source: any; + transaction: IDBTransaction; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransaction extends EventTarget { + db: IDBDatabase; + error: DOMError; + mode: string; + onabort: (ev: Event) => any; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface ImageData { + data: number[]; + height: number; + width: number; +} + +interface ImageDataConstructor { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +declare var ImageData: ImageDataConstructor; + +interface MSApp { + clearTemporaryWebDataAsync(): MSAppAsyncOperation; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createDataPackage(object: any): any; + createDataPackageFromSelection(): any; + createFileFromStorageFile(storageFile: any): File; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + getCurrentPriority(): string; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + CURRENT: string; + HIGH: string; + IDLE: string; + NORMAL: string; +} +declare var MSApp: MSApp; + +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSStream { + type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBinaryString(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MessageChannel { + port1: MessagePort; + port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + data: any; + origin: string; + ports: any; + source: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: any): void; +} + +declare var MessageEvent: { + prototype: MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +interface ProgressEvent extends Event { + lengthComputable: boolean; + loaded: number; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +declare var ProgressEvent: { + prototype: ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; +} + +interface WebSocket extends EventTarget { + binaryType: string; + bufferedAmount: number; + extensions: string; + onclose: (ev: CloseEvent) => any; + onerror: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onopen: (ev: Event) => any; + protocol: string; + readyState: number; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (ev: MessageEvent) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Worker: { + prototype: Worker; + new(stringUrl: string): Worker; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + msCaching: string; + onreadystatechange: (ev: ProgressEvent) => any; + readyState: number; + response: any; + responseBody: any; + responseText: string; + responseType: string; + responseXML: any; + status: number; + statusText: string; + timeout: number; + upload: XMLHttpRequestUpload; + withCredentials: boolean; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string; + msCachingEnabled(): boolean; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + overrideMimeType(mime: string): void; + send(data?: string): void; + send(data?: any): void; + setRequestHeader(header: string, value: string): void; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + create(): XMLHttpRequest; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + +interface AbstractWorker { + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface MSBaseReader { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + readyState: number; + result: any; + abort(): void; + DONE: number; + EMPTY: number; + LOADING: number; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface NavigatorID { + appName: string; + appVersion: string; + platform: string; + product: string; + productSub: string; + userAgent: string; + vendor: string; + vendorSub: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + console: Console; +} + +interface XMLHttpRequestEventTarget { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + ontimeout: (ev: ProgressEvent) => any; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface FileReaderSync { + readAsArrayBuffer(blob: Blob): any; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): string; + readAsText(blob: Blob, encoding?: string): string; +} + +declare var FileReaderSync: { + prototype: FileReaderSync; + new(): FileReaderSync; +} + +interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { + location: WorkerLocation; + onerror: (ev: Event) => any; + self: WorkerGlobalScope; + close(): void; + msWriteProfilerMark(profilerMarkName: string): void; + toString(): string; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WorkerGlobalScope: { + prototype: WorkerGlobalScope; + new(): WorkerGlobalScope; +} + +interface WorkerLocation { + hash: string; + host: string; + hostname: string; + href: string; + pathname: string; + port: string; + protocol: string; + search: string; + toString(): string; +} + +declare var WorkerLocation: { + prototype: WorkerLocation; + new(): WorkerLocation; +} + +interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WorkerNavigator: { + prototype: WorkerNavigator; + new(): WorkerNavigator; +} + +interface DedicatedWorkerGlobalScope { + onmessage: (ev: MessageEvent) => any; + postMessage(data: any): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface WorkerUtils extends Object, WindowBase64 { + indexedDB: IDBFactory; + msIndexedDB: IDBFactory; + navigator: WorkerNavigator; + clearImmediate(handle: number): void; + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + importScripts(...urls: string[]): void; + setImmediate(handler: any, ...args: any[]): number; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + +interface EventListenerObject { + handleEvent(evt: Event): void; +} + +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface ErrorEventHandler { + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; +} +interface PositionCallback { + (position: Position): void; +} +interface PositionErrorCallback { + (error: PositionError): void; +} +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} +interface MSLaunchUriCallback { + (): void; +} +interface MSUnsafeFunctionCallback { + (): any; +} +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} +interface DecodeSuccessCallback { + (decodedData: AudioBuffer): void; +} +interface DecodeErrorCallback { + (): void; +} +interface FunctionStringCallback { + (data: string): void; +} +declare var location: WorkerLocation; +declare var onerror: (ev: Event) => any; +declare var self: WorkerGlobalScope; +declare function close(): void; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function toString(): string; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare var indexedDB: IDBFactory; +declare var msIndexedDB: IDBFactory; +declare var navigator: WorkerNavigator; +declare function clearImmediate(handle: number): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function importScripts(...urls: string[]): void; +declare function setImmediate(handler: any, ...args: any[]): number; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare var onmessage: (ev: MessageEvent) => any; +declare function postMessage(data: any): void; +declare var console: Console; +declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/bin/tsc.js b/lib/tsc.js similarity index 86% rename from bin/tsc.js rename to lib/tsc.js index 185aca1ef44..0ccb839c2ef 100644 --- a/bin/tsc.js +++ b/lib/tsc.js @@ -57,6 +57,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +79,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +499,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -649,7 +653,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -864,7 +868,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +896,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +937,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +959,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +995,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1255,6 +1258,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1298,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1425,6 +1429,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1504,20 +1510,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1568,11 +1566,13 @@ var ts; Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,7 +1613,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -1621,123 +1622,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1839,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1903,6 +1905,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1963,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2020,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2111,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2150,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2291,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2465,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2497,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2540,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2643,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2655,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2665,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2675,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2691,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2703,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2726,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2746,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2812,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2871,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2893,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2909,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (token === 67) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -2949,16 +2984,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2974,7 +3009,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -3026,10 +3061,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3037,22 +3072,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -3094,7 +3129,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3140,37 +3175,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3186,33 +3221,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3236,11 +3271,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -3257,7 +3292,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -3267,12 +3302,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -3290,11 +3330,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3316,10 +3356,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3337,8 +3377,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3365,17 +3405,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3409,7 +3449,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3438,17 +3478,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -3467,106 +3507,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3587,12 +3627,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -3637,7 +3680,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3699,6 +3742,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3715,7 +3789,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3791,7 +3865,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3806,15 +3880,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3825,9 +3899,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3863,22 +3937,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3900,11 +3974,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3912,14 +3986,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3934,20 +4008,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3957,68 +4029,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -4029,23 +4101,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -4055,23 +4127,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133) { + if (name_5 && name_5.kind === 134) { traverse(name_5.expression); return; } @@ -4086,14 +4158,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -4101,41 +4173,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4163,36 +4249,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -4204,33 +4290,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -4239,12 +4325,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -4252,7 +4338,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -4260,40 +4346,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4304,10 +4390,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4319,92 +4405,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4422,7 +4509,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4431,20 +4518,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4452,15 +4539,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4468,9 +4553,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4484,24 +4569,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4520,12 +4605,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4534,19 +4619,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4561,34 +4646,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4596,25 +4681,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4623,13 +4708,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4637,11 +4722,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4655,54 +4740,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4771,11 +4856,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4784,19 +4869,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4811,21 +4896,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4833,20 +4918,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -5071,7 +5172,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -5083,7 +5184,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -5098,10 +5199,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -5110,7 +5211,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5121,10 +5222,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -5203,7 +5304,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -5230,16 +5331,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -5247,29 +5348,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -5277,12 +5378,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5291,10 +5392,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5302,10 +5403,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5509,9 +5621,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5523,7 +5635,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5561,20 +5673,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5583,24 +5695,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5611,160 +5723,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5776,125 +5881,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5990,9 +6102,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -6030,7 +6142,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6163,6 +6275,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -6186,20 +6301,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -6233,20 +6351,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6288,15 +6406,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6306,14 +6424,14 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 || - token === 7; + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6325,30 +6443,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6358,14 +6476,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6376,21 +6494,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6402,23 +6520,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: return isIdentifierOrKeyword(); case 13: - return isIdentifierOrKeyword() || token === 14; + return isIdentifierOrKeyword() || token === 15; case 14: return true; case 22: @@ -6431,10 +6549,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6447,8 +6565,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6470,39 +6588,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6512,7 +6630,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6617,17 +6735,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6636,8 +6754,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6646,65 +6764,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6759,15 +6877,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6803,8 +6921,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6815,34 +6933,34 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6860,7 +6978,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6869,30 +6987,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6903,20 +7021,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6925,15 +7043,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6945,7 +7063,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6957,7 +7075,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6965,7 +7083,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6973,29 +7091,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -7010,20 +7128,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -7031,17 +7149,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7051,9 +7169,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -7073,27 +7191,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -7117,18 +7235,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -7136,47 +7254,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -7184,19 +7302,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -7204,13 +7322,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -7232,32 +7350,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -7269,36 +7387,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7309,18 +7427,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7330,10 +7448,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7349,7 +7467,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7358,12 +7476,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7384,7 +7502,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7393,7 +7511,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7406,11 +7524,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7419,15 +7537,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7444,78 +7562,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7532,25 +7650,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7560,15 +7678,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7577,7 +7695,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7586,10 +7704,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7605,90 +7723,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7697,7 +7815,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7707,25 +7825,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7734,8 +7852,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7744,7 +7862,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7755,44 +7873,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7801,7 +7919,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7814,19 +7932,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7835,95 +7960,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7935,20 +8072,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7958,17 +8095,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7977,108 +8114,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -8089,37 +8226,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -8127,10 +8264,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -8138,7 +8275,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8149,20 +8286,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8187,47 +8324,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -8235,32 +8372,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -8268,7 +8405,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8276,8 +8413,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8285,99 +8422,99 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66; + return token >= 67; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -8385,51 +8522,51 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || isIdentifierOrKeyword(); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8442,44 +8579,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: - return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: - case 123: - case 129: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: + return isStartOfDeclaration(); + case 116: + case 120: + case 105: + case 123: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8487,71 +8624,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8564,33 +8701,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8600,34 +8737,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8635,33 +8772,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8670,21 +8807,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8696,10 +8833,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8707,29 +8844,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8737,12 +8874,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8755,10 +8892,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8773,16 +8910,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8790,7 +8927,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8800,26 +8937,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8831,14 +8968,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8872,7 +9009,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8886,8 +9023,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8898,42 +9035,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8952,8 +9089,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8962,24 +9099,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8987,32 +9124,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -9020,10 +9157,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -9031,18 +9168,18 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) + node.body = parseOptional(21) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9051,57 +9188,57 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -9114,13 +9251,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -9130,37 +9267,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9168,9 +9305,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9179,23 +9316,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9203,14 +9340,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9273,10 +9410,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9285,16 +9422,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } return isIdentifierOrKeyword(); @@ -9311,23 +9448,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9337,21 +9474,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9364,85 +9501,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9457,7 +9594,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9468,40 +9605,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9511,10 +9648,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9522,31 +9659,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9617,7 +9754,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9628,7 +9765,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9654,7 +9791,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9694,7 +9831,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9706,7 +9842,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9716,16 +9852,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9735,10 +9861,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9749,7 +9885,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_8.pos); + var typeParameter = createNode(135, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9760,7 +9896,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9781,7 +9917,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9825,7 +9961,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9855,9 +9991,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -10113,17 +10249,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10140,7 +10277,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10148,16 +10286,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10201,6 +10340,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10222,7 +10362,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10235,6 +10375,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10376,10 +10517,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10402,7 +10543,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10427,16 +10568,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10450,13 +10591,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10466,9 +10607,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10476,7 +10617,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10484,28 +10625,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10518,8 +10659,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10545,7 +10686,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10557,14 +10698,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10586,10 +10727,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -10599,7 +10740,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10688,17 +10829,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -10740,10 +10881,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10753,17 +10894,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10775,16 +10916,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10807,35 +10948,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -10931,7 +11061,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10996,17 +11126,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11039,7 +11169,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11068,7 +11198,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11123,8 +11253,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11156,11 +11286,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11211,16 +11341,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11229,10 +11358,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11253,7 +11382,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11295,7 +11424,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11319,23 +11448,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11343,22 +11472,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11373,7 +11502,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11381,18 +11510,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11409,7 +11538,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11430,7 +11559,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11439,7 +11568,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11455,74 +11584,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11534,32 +11663,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11568,7 +11697,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11576,67 +11705,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11656,15 +11785,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -11673,12 +11799,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11721,60 +11847,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -11789,11 +11915,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -11816,29 +11945,55 @@ var ts; }); } } - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11864,7 +12019,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -11877,9 +12032,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -11901,10 +12053,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11913,10 +12065,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11929,9 +12081,12 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } return undefined; } function getTypeFromBindingElement(element) { @@ -11958,7 +12113,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11973,7 +12128,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11983,15 +12138,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12004,13 +12156,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12032,7 +12184,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12045,11 +12197,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12075,7 +12227,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12164,9 +12316,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12175,15 +12327,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12219,7 +12371,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12288,7 +12440,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12332,10 +12484,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12366,7 +12518,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12533,38 +12685,59 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -12701,9 +12874,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -12721,7 +12891,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -12802,6 +12972,25 @@ var ts; } return undefined; } + function isKnownProperty(type, name) { + if (type.flags & 80896 && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -12857,12 +13046,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12871,14 +13070,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -12890,7 +13092,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -12900,8 +13102,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -12919,19 +13121,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12945,7 +13147,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13001,7 +13203,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13015,7 +13217,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13044,13 +13246,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13069,19 +13271,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13097,13 +13299,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13170,7 +13372,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13196,9 +13398,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13271,7 +13473,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -13297,20 +13499,68 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { + return true; + } + if (source.flags & 524288 && target.flags & 80896) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -13333,25 +13583,21 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - function getUnionType(types, noSubtypeReduction) { + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -13359,25 +13605,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13400,7 +13632,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13436,45 +13668,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13533,7 +13765,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13542,6 +13774,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -13597,6 +13831,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -13608,6 +13851,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -13635,27 +13879,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -13729,99 +13973,135 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; } + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -13892,30 +14172,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14092,22 +14359,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14131,6 +14388,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14219,7 +14500,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14232,7 +14513,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14256,7 +14537,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14333,14 +14614,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14360,16 +14645,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14424,6 +14711,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14451,7 +14755,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14495,7 +14799,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14509,22 +14813,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14537,7 +14841,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14573,7 +14877,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -14597,10 +14903,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -14624,6 +14930,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -14767,10 +15080,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -14810,12 +15123,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -14829,82 +15142,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -14914,34 +15205,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -14955,21 +15246,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15006,7 +15297,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15039,11 +15330,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15067,27 +15361,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15099,7 +15393,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15130,15 +15424,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15156,7 +15450,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15167,29 +15461,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15204,86 +15498,92 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; - if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { if (isFunctionExpressionOrArrowFunction(parameter.parent)) { @@ -15312,7 +15612,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15345,7 +15645,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15354,8 +15654,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15374,7 +15674,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15382,12 +15682,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15474,7 +15774,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15484,7 +15784,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15502,38 +15802,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15548,7 +15848,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15556,7 +15856,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15570,16 +15870,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -15596,17 +15892,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -15625,7 +15921,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15637,7 +15933,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -15648,7 +15944,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15663,7 +15959,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -15681,18 +15977,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -15707,7 +16003,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15718,7 +16014,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -15747,31 +16043,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -15780,7 +16079,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -15795,9 +16094,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -15860,7 +16167,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -15870,26 +16177,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -15903,14 +16210,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -15945,7 +16248,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16013,7 +16316,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16022,11 +16325,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16052,7 +16355,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16060,11 +16363,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16085,7 +16388,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16130,7 +16433,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16145,7 +16448,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16163,7 +16466,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16181,7 +16484,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16201,7 +16504,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16217,7 +16520,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16241,10 +16544,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16266,19 +16569,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16295,7 +16598,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16307,11 +16610,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16319,11 +16622,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16331,7 +16634,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16384,7 +16687,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16431,11 +16734,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16450,16 +16753,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16468,18 +16771,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16489,20 +16792,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16511,27 +16814,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16548,17 +16851,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -16580,26 +16883,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -16607,12 +16910,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -16675,6 +16978,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -16747,7 +17053,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -16792,7 +17098,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -16836,16 +17142,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -16873,16 +17179,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -16894,15 +17200,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -16915,7 +17221,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -16934,13 +17240,22 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -16958,7 +17273,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17062,7 +17377,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17071,7 +17386,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17084,9 +17399,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17098,33 +17413,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17141,7 +17461,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17173,17 +17493,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17191,22 +17511,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17249,17 +17569,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17315,7 +17635,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17324,7 +17644,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17336,7 +17656,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17361,8 +17681,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17387,7 +17707,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17400,14 +17720,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17421,32 +17741,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17465,8 +17785,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17490,42 +17810,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17535,21 +17855,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -17633,21 +17953,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -17663,7 +17983,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -17671,9 +17991,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -17686,78 +18006,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -17782,7 +18102,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -17797,15 +18117,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -17815,30 +18135,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -17847,7 +18167,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -17857,19 +18177,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -17893,10 +18213,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -17918,7 +18238,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -17933,7 +18253,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -17941,7 +18261,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -17981,48 +18301,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18030,13 +18371,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18121,9 +18462,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18141,7 +18482,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18217,7 +18558,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18249,11 +18590,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18332,35 +18673,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18495,22 +18851,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18519,29 +18875,33 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18564,24 +18924,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18604,7 +18964,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18639,11 +18999,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -18661,19 +19021,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -18687,7 +19047,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -18708,7 +19068,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -18721,11 +19081,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -18736,7 +19096,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -18746,15 +19106,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -18764,16 +19124,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -18793,7 +19153,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -18802,7 +19162,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -18830,9 +19190,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -18853,7 +19213,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -18886,12 +19246,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -18906,13 +19266,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -18927,7 +19287,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -18937,7 +19297,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19099,7 +19459,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19117,10 +19477,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19153,7 +19513,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19165,7 +19525,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19182,7 +19542,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19208,7 +19568,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19276,7 +19636,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19429,7 +19789,7 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -19470,7 +19830,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19536,7 +19896,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -19554,7 +19914,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -19586,28 +19946,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -19618,22 +19962,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19643,39 +20007,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -19687,25 +20051,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -19714,6 +20078,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -19747,7 +20113,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -19770,8 +20136,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -19793,7 +20159,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -19801,7 +20167,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -19822,7 +20188,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -19841,28 +20207,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -19881,7 +20247,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -19907,7 +20273,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -19942,7 +20308,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } } @@ -19958,8 +20324,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -19972,7 +20338,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -19986,15 +20352,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20011,10 +20377,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20051,182 +20417,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20236,27 +20601,28 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20334,7 +20700,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20356,34 +20722,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20407,42 +20776,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20454,10 +20823,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20466,29 +20835,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20497,54 +20868,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20558,7 +20940,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -20581,7 +20963,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -20589,14 +20971,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -20655,11 +21037,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -20672,11 +21054,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -20702,22 +21084,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -20728,7 +21110,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -20762,7 +21147,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -20776,13 +21161,17 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -20804,7 +21193,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -20846,13 +21235,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -20892,7 +21281,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -20973,7 +21363,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -20983,38 +21373,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21029,14 +21419,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21053,11 +21443,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21066,17 +21456,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21085,7 +21475,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21098,42 +21488,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21145,14 +21535,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21160,7 +21550,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21178,10 +21568,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21193,10 +21583,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21244,16 +21634,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21263,7 +21651,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21298,7 +21686,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21330,7 +21718,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21357,7 +21745,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21370,7 +21758,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21385,14 +21773,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21401,19 +21789,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21439,26 +21827,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 || - name_16.kind === 133) { + if (prop.kind === 185 || + name_16.kind === 134) { checkGrammarComputedPropertyName(name_16); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7) { + if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21490,7 +21878,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21502,7 +21890,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21511,24 +21899,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -21551,10 +21939,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21579,7 +21967,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21589,7 +21977,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21608,22 +21996,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21635,9 +22023,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -21645,8 +22033,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -21659,13 +22047,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -21677,7 +22065,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -21686,7 +22074,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -21706,7 +22094,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -21715,7 +22103,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -21732,15 +22120,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -21756,13 +22144,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -21775,7 +22163,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -21818,7 +22206,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -21838,12 +22226,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -21853,11 +22241,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -21867,7 +22255,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -21886,7 +22274,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -21959,7 +22347,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22032,10 +22420,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22046,7 +22434,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22054,12 +22442,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22146,62 +22534,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22277,7 +22665,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22295,7 +22683,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22313,10 +22701,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22325,7 +22713,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22343,23 +22731,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22373,7 +22761,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22420,7 +22808,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22446,7 +22834,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22502,7 +22890,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22519,14 +22907,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22563,7 +22955,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22573,15 +22965,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -22591,31 +22983,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -22643,9 +23035,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -22725,16 +23120,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -22743,14 +23138,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -22758,7 +23153,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -22784,7 +23179,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -22850,7 +23245,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -22863,7 +23258,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -22872,7 +23267,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -22918,17 +23313,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -22945,11 +23340,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -22958,20 +23353,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -22982,23 +23377,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144: + case 145: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23006,7 +23401,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23019,7 +23414,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23047,13 +23442,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23069,22 +23464,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145: + case 146: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23092,7 +23487,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23104,7 +23499,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210: + case 211: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23115,12 +23510,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23139,21 +23534,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23165,39 +23559,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23206,7 +23600,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23262,17 +23656,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23301,11 +23695,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23325,7 +23715,7 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -23396,7 +23786,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23408,19 +23798,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23474,7 +23864,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23559,7 +23949,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_21 = node.name; - if (!name_21 || name_21.kind !== 133) { + if (!name_21 || name_21.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23576,18 +23966,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_22 = node.name; - scopeName = name_22.kind === 133 + scopeName = name_22.kind === 134 ? ts.getTextOfNode(name_22) : node.name.text; } @@ -23686,7 +24076,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -23697,8 +24087,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -23710,7 +24103,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -23820,7 +24213,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -23846,7 +24241,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -23859,7 +24254,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -23871,23 +24266,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -23897,15 +24292,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -23931,11 +24326,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -23958,7 +24353,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -23991,11 +24386,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24003,20 +24398,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24029,10 +24424,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24040,9 +24435,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24068,36 +24463,36 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24117,15 +24512,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24137,11 +24532,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } @@ -24161,11 +24556,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24173,11 +24568,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24196,20 +24591,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24228,7 +24623,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24240,58 +24635,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24303,7 +24700,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24316,12 +24713,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -24334,17 +24731,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24359,6 +24761,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24418,7 +24823,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24432,7 +24837,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24440,22 +24845,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24472,17 +24877,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24505,7 +24910,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24566,7 +24971,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -24617,13 +25022,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -24655,7 +25060,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -24669,35 +25074,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -24719,11 +25124,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -24733,20 +25139,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -24769,9 +25180,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -24789,7 +25206,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -24805,11 +25222,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -24817,7 +25234,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -24832,16 +25249,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -24856,18 +25273,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -24876,7 +25293,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -24896,13 +25313,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -24953,20 +25370,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166)) { emit(operand); return; } @@ -24977,25 +25394,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25009,12 +25426,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25031,7 +25448,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25052,10 +25469,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25064,13 +25481,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25078,7 +25495,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25113,36 +25530,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25154,20 +25571,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25179,7 +25596,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25199,13 +25616,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25214,13 +25631,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25245,10 +25662,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25269,13 +25686,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25285,14 +25702,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -25316,10 +25733,10 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25339,7 +25756,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25347,13 +25764,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25362,7 +25779,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25374,17 +25791,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25396,12 +25813,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25412,21 +25829,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25441,7 +25858,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25476,16 +25893,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25496,7 +25913,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25515,16 +25932,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25535,7 +25969,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25543,6 +25977,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25561,44 +25996,48 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -25609,11 +26048,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -25629,7 +26068,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -25641,37 +26080,37 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -25685,7 +26124,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -25698,8 +26137,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -25709,14 +26148,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -25726,18 +26165,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -25757,11 +26199,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -25792,15 +26234,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -25811,11 +26253,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -25823,7 +26265,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -25831,7 +26273,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -25929,9 +26371,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -25950,7 +26392,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -25971,7 +26413,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -25980,26 +26422,26 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } @@ -26007,9 +26449,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26027,10 +26472,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26062,7 +26508,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26105,7 +26551,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26153,10 +26599,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26222,17 +26668,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26256,24 +26702,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26313,11 +26759,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26329,14 +26775,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26386,22 +26830,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { + if ((member.kind === 141 || node.kind === 140) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26412,7 +26856,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26433,10 +26877,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { + if (member.kind === 142 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26467,18 +26911,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26505,7 +26952,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26513,7 +26960,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26536,7 +26983,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26553,7 +27000,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -26580,7 +27027,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -26620,7 +27067,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -26658,7 +27105,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -26670,7 +27117,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -26678,11 +27125,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -26756,13 +27203,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26792,7 +27239,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26831,45 +27278,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -26880,43 +27327,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100: + case 101: write("void 0"); return; - case 157: + case 158: emitSerializedTypeNode(node.type); return; - case 149: case 150: + case 151: write("Function"); return; - case 153: case 154: + case 155: write("Array"); return; - case 147: - case 117: + case 148: + case 118: write("Boolean"); return; - case 127: - case 8: + case 128: + case 9: write("String"); return; - case 125: + case 126: write("Number"); return; - case 128: + case 129: write("Symbol"); return; - case 148: + case 149: emitSerializedTypeReferenceNode(node); return; - case 151: case 152: - case 155: + case 153: case 156: - case 114: + case 157: + case 115: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -26925,8 +27375,13 @@ var ts; write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -26975,7 +27430,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -26991,10 +27446,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27011,7 +27466,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27088,7 +27543,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27147,7 +27602,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27182,7 +27637,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27201,7 +27656,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27214,7 +27669,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27226,29 +27681,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27275,7 +27742,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27301,7 +27768,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27313,7 +27780,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27359,16 +27826,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27396,11 +27876,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27422,7 +27902,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27434,10 +27913,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27450,13 +27928,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27469,8 +27945,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27484,6 +27960,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27506,18 +27983,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27535,7 +28012,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27560,17 +28037,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -27582,8 +28059,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -27608,7 +28085,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -27637,7 +28114,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -27659,6 +28136,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -27666,17 +28145,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -27687,8 +28168,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -27707,7 +28188,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 + var name_25 = local.kind === 67 ? local : local.name; if (name_25) { @@ -27722,13 +28203,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -27756,21 +28237,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27779,7 +28260,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27788,10 +28269,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_26 = node.name; - if (name_26.kind === 66) { + if (name_26.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -27803,6 +28284,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -27817,12 +28305,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -27831,7 +28319,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -27839,75 +28327,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -27920,14 +28397,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -27943,8 +28431,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -27953,8 +28452,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28012,6 +28512,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28031,6 +28532,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28039,6 +28541,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28058,6 +28561,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28083,9 +28587,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28093,7 +28597,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28106,15 +28610,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28128,13 +28642,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28143,9 +28657,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28177,10 +28691,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28202,6 +28713,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28224,47 +28741,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28273,170 +28806,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28464,7 +28997,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28476,7 +29009,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28496,6 +29029,10 @@ var ts; var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { @@ -28541,6 +29078,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; @@ -28561,16 +29104,273 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -28587,6 +29387,172 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function useBaseUrl(moduleName) { + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -28649,7 +29615,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -28684,7 +29652,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -28695,14 +29663,30 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -28734,6 +29718,58 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -28760,7 +29796,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -28841,14 +29877,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -28879,15 +29952,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -28899,8 +29972,8 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -28910,11 +29983,11 @@ var ts; if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -28930,7 +30003,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -28938,49 +30016,30 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -29032,28 +30091,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -29061,16 +30120,20 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { @@ -29092,7 +30155,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29104,16 +30167,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { @@ -29154,6 +30223,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -29244,6 +30318,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -29342,20 +30422,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -29446,7 +30545,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -29519,6 +30618,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -29553,7 +30655,7 @@ var ts; function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); return false; } var language = matchResult[1]; @@ -29576,7 +30678,7 @@ var ts; if (!ts.sys.fileExists(filePath)) { return false; } - var fileContents = ''; + var fileContents = ""; try { fileContents = ts.sys.readFile(filePath); } @@ -29668,6 +30770,10 @@ var ts; reportDiagnostics(commandLine.errors); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return ts.sys.exit(ts.ExitStatus.Success); + } if (commandLine.options.version) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); return ts.sys.exit(ts.ExitStatus.Success); @@ -29823,16 +30929,15 @@ var ts; } return { program: program, exitStatus: exitStatus }; function compileProgram() { - var diagnostics = program.getSyntacticDiagnostics(); - reportDiagnostics(diagnostics); + var diagnostics; + diagnostics = program.getSyntacticDiagnostics(); if (diagnostics.length === 0) { - var diagnostics_1 = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics_1); - if (diagnostics_1.length === 0) { - var diagnostics_2 = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics_2); + diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + if (diagnostics.length === 0) { + diagnostics = program.getSemanticDiagnostics(); } } + reportDiagnostics(diagnostics); if (compilerOptions.noEmit) { return diagnostics.length ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped @@ -29910,5 +31015,60 @@ var ts; return Array(paddingLength + 1).join(" "); } } + function writeConfigFile(options, fileNames) { + var currentDirectory = ts.sys.getCurrentDirectory(); + var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + if (ts.sys.fileExists(file)) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + return; + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = ts.getOptionNameMap().optionNameMap; + for (var name_28 in options) { + if (ts.hasProperty(options, name_28)) { + var value = options[name_28]; + switch (name_28) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + result[name_28] = value; + } + else { + var typeMap = optionDefinition.type; + for (var key in typeMap) { + if (ts.hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name_28] = key; + } + } + } + } + break; + } + } + } + return result; + } + } })(ts || (ts = {})); ts.executeCommandLine(ts.sys.args); diff --git a/bin/tsserver.js b/lib/tsserver.js similarity index 86% rename from bin/tsserver.js rename to lib/tsserver.js index 9d582485e2f..3c339e6d661 100644 --- a/bin/tsserver.js +++ b/lib/tsserver.js @@ -57,6 +57,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +79,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +499,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -649,7 +653,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -864,7 +868,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +896,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +937,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +959,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +995,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1255,6 +1258,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1298,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1425,6 +1429,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1504,20 +1510,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1568,11 +1566,13 @@ var ts; Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,7 +1613,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -1621,123 +1622,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1839,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1903,6 +1905,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1963,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2020,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2111,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2150,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2291,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2465,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2497,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2540,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2643,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2655,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2665,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2675,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2691,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2703,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2726,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2746,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2812,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2871,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2893,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2909,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (token === 67) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -2975,6 +3010,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -3065,6 +3105,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -3163,20 +3209,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -3267,7 +3332,7 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -3340,6 +3405,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -3416,6 +3484,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3432,7 +3531,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3508,7 +3607,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3523,15 +3622,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3542,9 +3641,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3580,22 +3679,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3617,11 +3716,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3629,14 +3728,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3651,20 +3750,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3674,68 +3771,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -3746,23 +3843,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -3772,23 +3869,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 133) { + if (name_6 && name_6.kind === 134) { traverse(name_6.expression); return; } @@ -3803,14 +3900,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -3818,41 +3915,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3880,36 +3991,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -3921,33 +4032,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -3956,12 +4067,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -3969,7 +4080,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -3977,40 +4088,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4021,10 +4132,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4036,92 +4147,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4139,7 +4251,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4148,20 +4260,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4169,15 +4281,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4185,9 +4295,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4201,24 +4311,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4237,12 +4347,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4251,19 +4361,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4278,34 +4388,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4313,25 +4423,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4340,13 +4450,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4354,11 +4464,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4372,54 +4482,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4488,11 +4598,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4501,19 +4611,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4528,21 +4638,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4550,20 +4660,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -4788,7 +4914,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -4800,7 +4926,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -4815,10 +4941,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -4827,7 +4953,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4838,10 +4964,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -4920,7 +5046,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -4947,16 +5073,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -4964,29 +5090,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -4994,12 +5120,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5008,10 +5134,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5019,10 +5145,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5226,9 +5363,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5240,7 +5377,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5278,20 +5415,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5300,24 +5437,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5328,160 +5465,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5493,125 +5623,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5707,9 +5844,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -5747,7 +5884,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5880,6 +6017,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -5903,20 +6043,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -5950,20 +6093,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6005,15 +6148,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6023,14 +6166,14 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 || - token === 7; + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6042,30 +6185,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6075,14 +6218,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6093,21 +6236,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6119,23 +6262,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: return isIdentifierOrKeyword(); case 13: - return isIdentifierOrKeyword() || token === 14; + return isIdentifierOrKeyword() || token === 15; case 14: return true; case 22: @@ -6148,10 +6291,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6164,8 +6307,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6187,39 +6330,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6229,7 +6372,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6334,17 +6477,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6353,8 +6496,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6363,65 +6506,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6476,15 +6619,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6520,8 +6663,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6532,34 +6675,34 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6577,7 +6720,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6586,30 +6729,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6620,20 +6763,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6642,15 +6785,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6662,7 +6805,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6674,7 +6817,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6682,7 +6825,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6690,29 +6833,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -6727,20 +6870,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6748,17 +6891,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6768,9 +6911,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -6790,27 +6933,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -6834,18 +6977,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -6853,47 +6996,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -6901,19 +7044,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -6921,13 +7064,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -6949,32 +7092,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -6986,36 +7129,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7026,18 +7169,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7047,10 +7190,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { @@ -7066,7 +7209,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7075,12 +7218,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7101,7 +7244,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7110,7 +7253,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7123,11 +7266,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7136,15 +7279,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7161,78 +7304,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7249,25 +7392,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7277,15 +7420,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7294,7 +7437,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7303,10 +7446,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7322,90 +7465,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7414,7 +7557,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7424,25 +7567,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7451,8 +7594,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7461,7 +7604,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7472,44 +7615,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7518,7 +7661,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7531,19 +7674,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7552,95 +7702,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7652,20 +7814,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7675,17 +7837,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7694,108 +7856,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7806,37 +7968,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -7844,10 +8006,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -7855,7 +8017,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -7866,20 +8028,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -7904,47 +8066,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -7952,32 +8114,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -7985,7 +8147,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7993,8 +8155,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8002,99 +8164,99 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66; + return token >= 67; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -8102,51 +8264,51 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || isIdentifierOrKeyword(); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8159,44 +8321,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: - return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: - case 123: - case 129: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: + return isStartOfDeclaration(); + case 116: + case 120: + case 105: + case 123: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8204,71 +8366,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8281,33 +8443,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8317,34 +8479,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8352,33 +8514,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8387,21 +8549,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8413,10 +8575,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8424,29 +8586,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8454,12 +8616,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8472,10 +8634,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8490,16 +8652,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8507,7 +8669,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8517,26 +8679,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8548,14 +8710,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8589,7 +8751,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8603,8 +8765,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8615,42 +8777,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } if (isIdentifierOrKeyword() || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8669,8 +8831,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8679,24 +8841,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8704,32 +8866,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8737,10 +8899,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8748,18 +8910,18 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) + node.body = parseOptional(21) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8768,57 +8930,57 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -8831,13 +8993,13 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -8847,37 +9009,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8885,9 +9047,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -8896,23 +9058,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8920,14 +9082,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -8990,10 +9152,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9002,16 +9164,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } return isIdentifierOrKeyword(); @@ -9028,23 +9190,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9054,21 +9216,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9081,85 +9243,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9174,7 +9336,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9185,40 +9347,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9228,10 +9390,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9239,31 +9401,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9334,7 +9496,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9345,7 +9507,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9371,7 +9533,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9411,7 +9573,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9423,7 +9584,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9433,16 +9594,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9452,10 +9603,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9466,7 +9627,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_9.pos); + var typeParameter = createNode(135, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9477,7 +9638,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9498,7 +9659,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9542,7 +9703,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9572,9 +9733,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -9793,16 +9954,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9818,7 +9979,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -9870,10 +10031,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9881,22 +10042,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -9938,7 +10099,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9984,37 +10145,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10030,33 +10191,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10080,11 +10241,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -10101,7 +10262,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -10111,12 +10272,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -10134,11 +10300,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10160,10 +10326,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10181,8 +10347,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10209,17 +10375,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10253,7 +10419,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10282,17 +10448,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -10311,106 +10477,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10431,12 +10597,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -10481,7 +10650,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10536,17 +10705,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10563,7 +10733,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10571,16 +10742,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10624,6 +10796,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10645,7 +10818,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10658,6 +10831,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10799,10 +10973,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10825,7 +10999,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10850,16 +11024,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10873,13 +11047,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10889,9 +11063,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10899,7 +11073,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10907,28 +11081,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10941,8 +11115,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10968,7 +11142,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10980,14 +11154,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -11009,10 +11183,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -11022,7 +11196,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11111,17 +11285,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -11163,10 +11337,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11176,17 +11350,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11198,16 +11372,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11230,35 +11404,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -11354,7 +11517,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11419,17 +11582,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11462,7 +11625,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11491,7 +11654,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11546,8 +11709,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11579,11 +11742,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11634,16 +11797,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11652,10 +11814,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11676,7 +11838,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11718,7 +11880,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11742,23 +11904,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11766,22 +11928,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11796,7 +11958,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11804,18 +11966,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11832,7 +11994,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11853,7 +12015,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11862,7 +12024,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11878,74 +12040,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11957,32 +12119,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11991,7 +12153,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11999,67 +12161,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12079,15 +12241,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -12096,12 +12255,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12144,60 +12303,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -12212,11 +12371,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -12239,29 +12401,55 @@ var ts; }); } } - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12287,7 +12475,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12300,9 +12488,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -12324,10 +12509,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12336,10 +12521,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12352,9 +12537,12 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } return undefined; } function getTypeFromBindingElement(element) { @@ -12381,7 +12569,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -12396,7 +12584,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 + return pattern.kind === 159 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -12406,15 +12594,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12427,13 +12612,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12455,7 +12640,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12468,11 +12653,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12498,7 +12683,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12587,9 +12772,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12598,15 +12783,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12642,7 +12827,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12711,7 +12896,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12755,10 +12940,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12789,7 +12974,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12956,38 +13141,59 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -13124,9 +13330,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -13144,7 +13347,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -13225,6 +13428,25 @@ var ts; } return undefined; } + function isKnownProperty(type, name) { + if (type.flags & 80896 && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); @@ -13280,12 +13502,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13294,14 +13526,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -13313,7 +13548,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13323,8 +13558,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13342,19 +13577,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13368,7 +13603,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13424,7 +13659,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13438,7 +13673,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13467,13 +13702,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13492,19 +13727,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13520,13 +13755,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13593,7 +13828,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13619,9 +13854,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13694,7 +13929,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -13720,20 +13955,68 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) { + return true; + } + if (source.flags & 524288 && target.flags & 80896) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -13756,25 +14039,21 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - function getUnionType(types, noSubtypeReduction) { + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -13782,25 +14061,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13823,7 +14088,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13859,45 +14124,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13956,7 +14221,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13965,6 +14230,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -14020,6 +14287,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -14031,6 +14307,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -14058,27 +14335,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -14152,99 +14429,135 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; } + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -14315,30 +14628,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14515,22 +14815,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14554,6 +14844,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14642,7 +14956,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14655,7 +14969,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14679,7 +14993,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14756,14 +15070,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14783,16 +15101,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14847,6 +15167,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14874,7 +15211,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14918,7 +15255,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14932,22 +15269,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14960,7 +15297,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14996,7 +15333,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -15020,10 +15359,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -15047,6 +15386,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -15190,10 +15536,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -15233,12 +15579,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15252,82 +15598,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -15337,34 +15661,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -15378,21 +15702,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15429,7 +15753,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15462,11 +15786,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15490,27 +15817,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15522,7 +15849,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15553,15 +15880,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15579,7 +15906,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15590,29 +15917,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15627,86 +15954,92 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; - if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } + if (isCallExpression) { + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { if (isFunctionExpressionOrArrowFunction(parameter.parent)) { @@ -15735,7 +16068,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15768,7 +16101,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15777,8 +16110,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15797,7 +16130,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15805,12 +16138,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15897,7 +16230,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15907,7 +16240,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15925,38 +16258,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15971,7 +16304,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15979,7 +16312,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15993,16 +16326,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -16019,17 +16348,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -16048,7 +16377,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16060,7 +16389,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -16071,7 +16400,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16086,7 +16415,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -16104,18 +16433,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -16130,7 +16459,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16141,7 +16470,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -16170,31 +16499,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -16203,7 +16535,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -16218,9 +16550,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -16283,7 +16623,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -16293,26 +16633,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -16326,14 +16666,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -16368,7 +16704,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16436,7 +16772,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16445,11 +16781,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16475,7 +16811,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16483,11 +16819,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16508,7 +16844,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16553,7 +16889,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16568,7 +16904,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16586,7 +16922,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16604,7 +16940,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16624,7 +16960,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16640,7 +16976,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16664,10 +17000,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16689,19 +17025,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16718,7 +17054,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16730,11 +17066,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16742,11 +17078,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16754,7 +17090,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16807,7 +17143,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16854,11 +17190,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16873,16 +17209,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16891,18 +17227,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16912,20 +17248,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16934,27 +17270,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16971,17 +17307,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -17003,26 +17339,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -17030,12 +17366,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17098,6 +17434,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -17170,7 +17509,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17215,7 +17554,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -17259,16 +17598,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17296,16 +17635,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17317,15 +17656,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -17338,7 +17677,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -17357,13 +17696,22 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -17381,7 +17729,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17485,7 +17833,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17494,7 +17842,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17507,9 +17855,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17521,33 +17869,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17564,7 +17917,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17596,17 +17949,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17614,22 +17967,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_13 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17672,17 +18025,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17738,7 +18091,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17747,7 +18100,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17759,7 +18112,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17784,8 +18137,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17810,7 +18163,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17823,14 +18176,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17844,32 +18197,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17888,8 +18241,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17913,42 +18266,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17958,21 +18311,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -18056,21 +18409,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -18086,7 +18439,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -18094,9 +18447,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -18109,78 +18462,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18205,7 +18558,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18220,15 +18573,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -18238,30 +18591,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18270,7 +18623,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -18280,19 +18633,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -18316,10 +18669,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18341,7 +18694,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18356,7 +18709,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18364,7 +18717,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18404,48 +18757,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18453,13 +18827,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18544,9 +18918,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18564,7 +18938,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18640,7 +19014,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18672,11 +19046,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18755,35 +19129,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18918,22 +19307,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18942,29 +19331,33 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18987,24 +19380,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19027,7 +19420,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19062,11 +19455,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -19084,19 +19477,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19110,7 +19503,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19131,7 +19524,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19144,11 +19537,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -19159,7 +19552,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19169,15 +19562,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19187,16 +19580,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19216,7 +19609,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19225,7 +19618,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19253,9 +19646,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19276,7 +19669,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19309,12 +19702,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19329,13 +19722,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19350,7 +19743,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -19360,7 +19753,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19522,7 +19915,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19540,10 +19933,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19576,7 +19969,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19588,7 +19981,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19605,7 +19998,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19631,7 +20024,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19699,7 +20092,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19852,7 +20245,7 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } @@ -19893,7 +20286,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19959,7 +20352,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -19977,7 +20370,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -20009,28 +20402,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -20041,22 +20418,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20066,39 +20463,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -20110,25 +20507,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -20137,6 +20534,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -20170,7 +20569,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -20193,8 +20592,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20216,7 +20615,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -20224,7 +20623,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -20245,7 +20644,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20264,28 +20663,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -20304,7 +20703,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -20330,7 +20729,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -20365,7 +20764,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } } @@ -20381,8 +20780,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20395,7 +20794,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20409,15 +20808,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20434,10 +20833,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20474,182 +20873,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20659,27 +21057,28 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20757,7 +21156,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20779,34 +21178,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20830,42 +21232,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20877,10 +21279,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20889,29 +21291,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20920,54 +21324,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20981,7 +21396,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21004,7 +21419,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -21012,14 +21427,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -21078,11 +21493,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21095,11 +21510,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -21125,22 +21540,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21151,7 +21566,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -21185,7 +21603,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21199,13 +21617,17 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -21227,7 +21649,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -21269,13 +21691,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -21315,7 +21737,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -21396,7 +21819,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21406,38 +21829,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21452,14 +21875,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21476,11 +21899,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21489,17 +21912,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21508,7 +21931,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21521,42 +21944,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21568,14 +21991,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21583,7 +22006,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21601,10 +22024,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21616,10 +22039,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21667,16 +22090,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21686,7 +22107,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21721,7 +22142,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21753,7 +22174,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21780,7 +22201,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21793,7 +22214,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21808,14 +22229,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21824,19 +22245,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21862,26 +22283,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 184 || - name_17.kind === 133) { + if (prop.kind === 185 || + name_17.kind === 134) { checkGrammarComputedPropertyName(name_17); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { + if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21913,7 +22334,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21925,7 +22346,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21934,24 +22355,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -21974,10 +22395,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22002,7 +22423,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22012,7 +22433,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22031,22 +22452,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22058,9 +22479,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -22068,8 +22489,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -22082,13 +22503,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -22100,7 +22521,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22109,7 +22530,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22129,7 +22550,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22138,7 +22559,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22155,15 +22576,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22179,13 +22600,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -22198,7 +22619,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -22241,7 +22662,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22261,12 +22682,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22276,11 +22697,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22290,7 +22711,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22309,7 +22730,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -22382,7 +22803,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22455,10 +22876,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22469,7 +22890,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22477,12 +22898,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22569,62 +22990,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22700,7 +23121,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22718,7 +23139,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22736,10 +23157,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22748,7 +23169,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22766,23 +23187,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22796,7 +23217,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22843,7 +23264,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22869,7 +23290,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22925,7 +23346,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22942,14 +23363,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22986,7 +23411,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22996,15 +23421,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -23014,31 +23439,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23066,9 +23491,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -23148,16 +23576,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23166,14 +23594,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23181,7 +23609,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23207,7 +23635,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -23273,7 +23701,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23286,7 +23714,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23295,7 +23723,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -23341,17 +23769,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -23368,11 +23796,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -23381,20 +23809,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23405,23 +23833,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144: + case 145: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23429,7 +23857,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23442,7 +23870,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23470,13 +23898,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23492,22 +23920,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145: + case 146: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23515,7 +23943,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23527,7 +23955,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210: + case 211: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23538,12 +23966,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23562,21 +23990,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23588,39 +24015,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23629,7 +24056,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23685,17 +24112,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23724,11 +24151,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23748,7 +24171,7 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; @@ -23819,7 +24242,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23831,19 +24254,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23897,7 +24320,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23982,7 +24405,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_22 = node.name; - if (!name_22 || name_22.kind !== 133) { + if (!name_22 || name_22.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23999,18 +24422,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_23 = node.name; - scopeName = name_23.kind === 133 + scopeName = name_23.kind === 134 ? ts.getTextOfNode(name_23) : node.name.text; } @@ -24109,7 +24532,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -24120,8 +24543,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -24133,7 +24559,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -24243,7 +24669,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -24269,7 +24697,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -24282,7 +24710,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -24294,23 +24722,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -24320,15 +24748,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -24354,11 +24782,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -24381,7 +24809,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -24414,11 +24842,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24426,20 +24854,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24452,10 +24880,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24463,9 +24891,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24491,36 +24919,36 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24540,15 +24968,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24560,11 +24988,11 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } @@ -24584,11 +25012,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24596,11 +25024,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24619,20 +25047,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24651,7 +25079,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24663,58 +25091,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24726,7 +25156,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24739,12 +25169,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -24757,17 +25187,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24782,6 +25217,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24841,7 +25279,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24855,7 +25293,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24863,22 +25301,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24895,17 +25333,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24928,7 +25366,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24989,7 +25427,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -25040,13 +25478,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -25078,7 +25516,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -25092,35 +25530,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -25142,11 +25580,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -25156,20 +25595,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -25192,9 +25636,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -25212,7 +25662,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -25228,11 +25678,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -25240,7 +25690,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25255,16 +25705,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -25279,18 +25729,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -25299,7 +25749,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -25319,13 +25769,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -25376,20 +25826,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166)) { emit(operand); return; } @@ -25400,25 +25850,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25432,12 +25882,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25454,7 +25904,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25475,10 +25925,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25487,13 +25937,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25501,7 +25951,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25536,36 +25986,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25577,20 +26027,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25602,7 +26052,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25622,13 +26072,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25637,13 +26087,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25668,10 +26118,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25692,13 +26142,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25708,14 +26158,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -25739,10 +26189,10 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25762,7 +26212,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25770,13 +26220,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25785,7 +26235,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25797,17 +26247,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25819,12 +26269,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25835,21 +26285,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25864,7 +26314,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25899,16 +26349,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25919,7 +26369,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25938,16 +26388,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25958,7 +26425,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25966,6 +26433,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25984,44 +26452,48 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -26032,11 +26504,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -26052,7 +26524,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66) { + if (expr.kind !== 67) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -26064,37 +26536,37 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -26108,7 +26580,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -26121,8 +26593,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26132,14 +26604,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -26149,18 +26621,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -26180,11 +26655,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -26215,15 +26690,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -26234,11 +26709,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -26246,7 +26721,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -26254,7 +26729,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -26352,9 +26827,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -26373,7 +26848,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -26394,7 +26869,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -26403,26 +26878,26 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } @@ -26430,9 +26905,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26450,10 +26928,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26485,7 +26964,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26528,7 +27007,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26576,10 +27055,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26645,17 +27124,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26679,24 +27158,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26736,11 +27215,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -26752,14 +27231,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26809,22 +27286,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { + if ((member.kind === 141 || node.kind === 140) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26835,7 +27312,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26856,10 +27333,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { + if (member.kind === 142 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26890,18 +27367,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26928,7 +27408,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26936,7 +27416,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26959,7 +27439,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26976,7 +27456,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -27003,7 +27483,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -27043,7 +27523,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27081,7 +27561,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -27093,7 +27573,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -27101,11 +27581,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -27179,13 +27659,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27215,7 +27695,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27254,45 +27734,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -27303,43 +27783,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100: + case 101: write("void 0"); return; - case 157: + case 158: emitSerializedTypeNode(node.type); return; - case 149: case 150: + case 151: write("Function"); return; - case 153: case 154: + case 155: write("Array"); return; - case 147: - case 117: + case 148: + case 118: write("Boolean"); return; - case 127: - case 8: + case 128: + case 9: write("String"); return; - case 125: + case 126: write("Number"); return; - case 128: + case 129: write("Symbol"); return; - case 148: + case 149: emitSerializedTypeReferenceNode(node); return; - case 151: case 152: - case 155: + case 153: case 156: - case 114: + case 157: + case 115: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -27348,8 +27831,13 @@ var ts; write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -27398,7 +27886,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -27414,10 +27902,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27434,7 +27922,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27511,7 +27999,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27570,7 +28058,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27605,7 +28093,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27624,7 +28112,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27637,7 +28125,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27649,29 +28137,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27698,7 +28198,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27724,7 +28224,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27736,7 +28236,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27782,16 +28282,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27819,11 +28332,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27845,7 +28358,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27857,10 +28369,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27873,13 +28384,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27892,8 +28401,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27907,6 +28416,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27929,18 +28439,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27958,7 +28468,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27983,17 +28493,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -28005,8 +28515,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -28031,7 +28541,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -28060,7 +28570,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -28082,6 +28592,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -28089,17 +28601,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -28110,8 +28624,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -28130,7 +28644,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_26 = local.kind === 66 + var name_26 = local.kind === 67 ? local : local.name; if (name_26) { @@ -28145,13 +28659,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -28179,21 +28693,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28202,7 +28716,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28211,10 +28725,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_27 = node.name; - if (name_27.kind === 66) { + if (name_27.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -28226,6 +28740,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -28240,12 +28761,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -28254,7 +28775,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -28262,75 +28783,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -28343,14 +28853,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -28366,8 +28887,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -28376,8 +28908,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -28435,6 +28968,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28454,6 +28988,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28462,6 +28997,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28481,6 +29017,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28506,9 +29043,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28516,7 +29053,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28529,15 +29066,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28551,13 +29098,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28566,9 +29113,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28600,10 +29147,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28625,6 +29169,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28647,47 +29197,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28696,170 +29262,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28887,7 +29453,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28899,7 +29465,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -28919,6 +29485,10 @@ var ts; var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } function emitLeadingCommentsOfPosition(pos) { var leadingComments; if (hasDetachedComments(pos)) { @@ -28964,6 +29534,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; @@ -28984,16 +29560,273 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -29010,6 +29843,172 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function useBaseUrl(moduleName) { + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -29072,7 +30071,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -29107,7 +30108,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -29118,14 +30119,30 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -29157,6 +30174,58 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -29183,7 +30252,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -29264,14 +30333,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -29302,15 +30408,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -29322,8 +30428,8 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -29333,11 +30439,11 @@ var ts; if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -29353,7 +30459,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -29361,49 +30472,30 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -29455,28 +30547,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -29484,16 +30576,20 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { @@ -29515,7 +30611,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29527,16 +30623,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { @@ -29587,128 +30689,128 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } - if (node.parent.kind === 196) { + if (node.parent.kind === 197) { return textSpan(node); } - if (node.parent.kind === 178 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 171 && node.parent.body === node) { + if (node.parent.kind === 172 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 190: + case 191: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208: - case 138: - case 137: - return spanInVariableDeclaration(node); - case 135: - return spanInParameterDeclaration(node); - case 210: - case 140: + case 209: case 139: - case 142: - case 143: + case 138: + return spanInVariableDeclaration(node); + case 136: + return spanInParameterDeclaration(node); + case 211: case 141: - case 170: + case 140: + case 143: + case 144: + case 142: case 171: + case 172: return spanInFunctionDeclaration(node); - case 189: + case 190: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 216: + case 217: return spanInBlock(node); - case 241: + case 242: return spanInBlock(node.block); - case 192: - return textSpan(node.expression); - case 201: - return textSpan(node.getChildAt(0), node.expression); - case 195: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 194: - return spanInNode(node.statement); - case 207: - return textSpan(node.getChildAt(0)); case 193: + return textSpan(node.expression); + case 202: + return textSpan(node.getChildAt(0), node.expression); + case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 195: + return spanInNode(node.statement); + case 208: + return textSpan(node.getChildAt(0)); + case 194: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 205: + return spanInNode(node.statement); + case 201: + case 200: + return textSpan(node.getChildAt(0), node.label); + case 197: + return spanInForStatement(node); + case 198: + case 199: return textSpan(node, ts.findNextToken(node.expression, node)); case 204: - return spanInNode(node.statement); - case 200: - case 199: - return textSpan(node.getChildAt(0), node.label); - case 196: - return spanInForStatement(node); - case 197: - case 198: return textSpan(node, ts.findNextToken(node.expression, node)); - case 203: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 238: case 239: + case 240: return spanInNode(node.statements[0]); - case 206: + case 207: return spanInBlock(node.tryBlock); - case 205: + case 206: return textSpan(node, node.expression); - case 224: - return textSpan(node, node.expression); - case 218: - return textSpan(node, node.moduleReference); - case 219: - return textSpan(node, node.moduleSpecifier); case 225: + return textSpan(node, node.expression); + case 219: + return textSpan(node, node.moduleReference); + case 220: return textSpan(node, node.moduleSpecifier); - case 215: + case 226: + return textSpan(node, node.moduleSpecifier); + case 216: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 211: - case 214: - case 244: - case 165: - case 166: - return textSpan(node); - case 202: - return spanInNode(node.statement); case 212: + case 215: + case 245: + case 166: + case 167: + return textSpan(node); + case 203: + return spanInNode(node.statement); case 213: + case 214: return undefined; - case 22: + case 23: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23: - return spanInPreviousNode(node); - case 14: - return spanInOpenBraceToken(node); - case 15: - return spanInCloseBraceToken(node); - case 16: - return spanInOpenParenToken(node); - case 17: - return spanInCloseParenToken(node); - case 52: - return spanInColonToken(node); - case 26: case 24: + return spanInPreviousNode(node); + case 15: + return spanInOpenBraceToken(node); + case 16: + return spanInCloseBraceToken(node); + case 17: + return spanInOpenParenToken(node); + case 18: + return spanInCloseParenToken(node); + case 53: + return spanInColonToken(node); + case 27: + case 25: return spanInGreaterThanOrLessThanToken(node); - case 101: + case 102: return spanInWhileKeyword(node); - case 77: - case 69: - case 82: + case 78: + case 70: + case 83: return spanInNextNode(node); default: - if (node.parent.kind === 242 && node.parent.name === node) { + if (node.parent.kind === 243 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 168 && node.parent.type === node) { + if (node.parent.kind === 169 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -29718,12 +30820,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 197 || - variableDeclaration.parent.parent.kind === 198) { + if (variableDeclaration.parent.parent.kind === 198 || + variableDeclaration.parent.parent.kind === 199) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -29769,7 +30871,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 211 && functionDeclaration.kind !== 141); + (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -29789,23 +30891,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215: + case 216: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 195: - case 193: - case 197: - case 198: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 196: + case 194: + case 198: + case 199: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 197: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209) { + if (forStatement.initializer.kind === 210) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -29824,34 +30926,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214: + case 215: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211: + case 212: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217: + case 218: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216: + case 217: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 214: - case 211: + case 215: + case 212: return textSpan(node); - case 189: + case 190: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 241: + case 242: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217: + case 218: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -29863,24 +30965,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 170: - case 210: case 171: - case 140: - case 139: - case 142: - case 143: + case 211: + case 172: case 141: - case 195: - case 194: + case 140: + case 143: + case 144: + case 142: case 196: + case 195: + case 197: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -29888,19 +30990,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168) { + if (node.parent.kind === 169) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -29978,7 +31080,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171; + return ts.isFunctionBlock(node) && node.parent.kind !== 172; } var depth = 0; var maxDepth = 20; @@ -29990,30 +31092,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189: + case 190: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_8.kind === 194 || - parent_8.kind === 197 || - parent_8.kind === 198 || - parent_8.kind === 196 || - parent_8.kind === 193 || - parent_8.kind === 195 || - parent_8.kind === 202 || - parent_8.kind === 241) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + if (parent_7.kind === 195 || + parent_7.kind === 198 || + parent_7.kind === 199 || + parent_7.kind === 197 || + parent_7.kind === 194 || + parent_7.kind === 196 || + parent_7.kind === 203 || + parent_7.kind === 242) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206) { - var tryStatement = parent_8; + if (parent_7.kind === 207) { + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -30029,25 +31131,25 @@ var ts; }); break; } - case 216: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 217: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211: case 212: - case 214: - case 162: - case 217: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 213: + case 215: + case 163: + case 218: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161: - var openBracket = ts.findChildOfKind(n, 18, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19, sourceFile); + case 162: + var openBracket = ts.findChildOfKind(n, 19, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -30115,9 +31217,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -30129,7 +31231,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133) { + else if (declaration.name.kind === 134) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -30146,7 +31248,7 @@ var ts; } return true; } - if (expression.kind === 163) { + if (expression.kind === 164) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -30157,7 +31259,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -30221,14 +31323,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215: + case 216: do { current = current.parent; - } while (current.kind === 215); - case 211: - case 214: + } while (current.kind === 216); case 212: - case 210: + case 215: + case 213: + case 211: indent++; } current = current.parent; @@ -30239,26 +31341,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190: + case 191: ts.forEach(node.declarationList.declarations, visit); break; - case 158: case 159: + case 160: ts.forEach(node.elements, visit); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { childNodes.push(importClause.namedBindings); } else { @@ -30267,20 +31369,20 @@ var ts; } } break; - case 160: - case 208: + case 161: + case 209: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 211: - case 214: case 212: case 215: - case 210: - case 218: - case 223: - case 227: + case 213: + case 216: + case 211: + case 219: + case 224: + case 228: childNodes.push(node); break; } @@ -30315,17 +31417,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211: - case 214: case 212: + case 215: + case 213: topLevelNodes.push(node); break; - case 215: + case 216: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210: + case 211: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -30336,9 +31438,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210) { - if (functionDeclaration.body && functionDeclaration.body.kind === 189) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 211) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -30391,7 +31493,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135: + case 136: if (ts.isBindingPattern(node.name)) { break; } @@ -30399,34 +31501,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 141: case 140: - case 139: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 143: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 144: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138: - case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 147: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 245: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210: + case 145: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 146: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 139: + case 138: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 211: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208: - case 160: + case 209: + case 161: var variableDeclarationNode; var name_29; - if (node.kind === 160) { + if (node.kind === 161) { name_29 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 208) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -30445,13 +31547,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141: + case 142: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227: - case 223: - case 218: - case 220: + case 228: + case 224: + case 219: case 221: + case 222: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -30481,27 +31583,27 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245: + case 246: return createSourceFileItem(node); - case 211: - return createClassItem(node); - case 214: - return createEnumItem(node); case 212: - return createIterfaceItem(node); + return createClassItem(node); case 215: + return createEnumItem(node); + case 213: + return createIterfaceItem(node); + case 216: return createModuleItem(node); - case 210: + case 211: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 8) { + if (moduleDeclaration.name.kind === 9) { return getTextOfNode(moduleDeclaration.name); } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -30513,7 +31615,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189) { + if (node.body && node.body.kind === 190) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -30534,7 +31636,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -30555,19 +31657,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215) { + while (node.body.kind === 216) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 + return node.kind === 246 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -31058,14 +32160,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165) { + if (argumentInfo.invocation.kind !== 166) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 + var name = expression.kind === 67 ? expression - : expression.kind === 163 + : expression.kind === 164 ? expression.name : undefined; if (!name || !name.text) { @@ -31094,10 +32196,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 || node.parent.kind === 166) { + if (node.parent.kind === 166 || node.parent.kind === 167) { var callExpression = node.parent; - if (node.kind === 24 || - node.kind === 16) { + if (node.kind === 25 || + node.kind === 17) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -31125,24 +32227,24 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 167) { + else if (node.kind === 11 && node.parent.kind === 168) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 167) { + else if (node.kind === 12 && node.parent.parent.kind === 168) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); + ts.Debug.assert(templateExpression.kind === 181); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 && node.parent.parent.parent.kind === 167) { + else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); - if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 181); + if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -31159,7 +32261,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23) { + if (child.kind !== 24) { argumentIndex++; } } @@ -31167,8 +32269,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { argumentCount++; } return argumentCount; @@ -31184,7 +32286,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - var argumentCount = tagExpression.template.kind === 10 + var argumentCount = tagExpression.template.kind === 11 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -31205,7 +32307,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 180) { + if (template.kind === 181) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -31214,7 +32316,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245; n = n.parent) { + for (var n = node; n.kind !== 246; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -31264,10 +32366,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24)); + prefixDisplayParts.push(ts.punctuationPart(25)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26)); + suffixDisplayParts.push(ts.punctuationPart(27)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -31278,10 +32380,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16)); + prefixDisplayParts.push(ts.punctuationPart(17)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17)); + suffixDisplayParts.push(ts.punctuationPart(18)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -31291,7 +32393,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -31314,12 +32416,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -31395,101 +32496,101 @@ var ts; return false; } switch (n.kind) { - case 211: case 212: - case 214: - case 162: - case 158: - case 152: - case 189: - case 216: + case 213: + case 215: + case 163: + case 159: + case 153: + case 190: case 217: - return nodeEndsWith(n, 15, sourceFile); - case 241: + case 218: + return nodeEndsWith(n, 16, sourceFile); + case 242: return isCompletedNode(n.block, sourceFile); - case 166: + case 167: if (!n.arguments) { return true; } - case 165: - case 169: - case 157: - return nodeEndsWith(n, 17, sourceFile); - case 149: + case 166: + case 170: + case 158: + return nodeEndsWith(n, 18, sourceFile); case 150: + case 151: return isCompletedNode(n.type, sourceFile); - case 141: case 142: case 143: - case 210: - case 170: - case 140: - case 139: - case 145: case 144: + case 211: case 171: + case 141: + case 140: + case 146: + case 145: + case 172: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 17, sourceFile); - case 215: + return hasChildOfKind(n, 18, sourceFile); + case 216: return n.body && isCompletedNode(n.body, sourceFile); - case 193: + case 194: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192: + case 193: return isCompletedNode(n.expression, sourceFile); - case 161: - case 159: - case 164: - case 133: - case 154: - return nodeEndsWith(n, 19, sourceFile); - case 146: + case 162: + case 160: + case 165: + case 134: + case 155: + return nodeEndsWith(n, 20, sourceFile); + case 147: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19, sourceFile); - case 238: + return hasChildOfKind(n, 20, sourceFile); case 239: + case 240: return false; - case 196: case 197: case 198: - case 195: + case 199: + case 196: return isCompletedNode(n.statement, sourceFile); - case 194: - var hasWhileKeyword = findChildOfKind(n, 101, sourceFile); + case 195: + var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); + return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151: + case 152: return isCompletedNode(n.exprName, sourceFile); - case 173: - case 172: case 174: - case 181: + case 173: + case 175: case 182: + case 183: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167: + case 168: return isCompletedNode(n.template, sourceFile); - case 180: + case 181: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187: + case 188: return ts.nodeIsPresent(n.literal); - case 176: + case 177: return isCompletedNode(n.operand, sourceFile); - case 178: - return isCompletedNode(n.right, sourceFile); case 179: + return isCompletedNode(n.right, sourceFile); + case 180: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -31503,7 +32604,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 && children.length !== 1) { + else if (last.kind === 23 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -31532,7 +32633,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 268 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -31638,7 +32739,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245); + ts.Debug.assert(startNode !== undefined || n.kind === 246); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -31653,6 +32754,67 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, undefined); + } + ts.isInComment = isInComment; + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100: + case 106: + case 72: + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { return n.getWidth() !== 0; } @@ -31677,32 +32839,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 || node.kind === 165) { + if (node.kind === 149 || node.kind === 166) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 || node.kind === 212) { + if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 131; + return n.kind >= 0 && n.kind <= 132; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 || ts.isKeyword(kind); + return kind === 67 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 || kind === 7 || isWord(kind); + return kind === 9 || kind === 8 || isWord(kind); } function isComment(kind) { return kind === 2 || kind === 3; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 65; + return 15 <= kind && kind <= 66; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -31712,9 +32874,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109: - case 107: + case 110: case 108: + case 109: return true; } return false; @@ -31740,7 +32902,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -31875,6 +33037,11 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -31915,7 +33082,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 || location.parent.kind === 227) && + (location.parent.kind === 224 || location.parent.kind === 228) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -31998,25 +33165,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28: - case 61: + case 29: case 62: + case 63: + case 44: case 43: - case 42: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9; + return container.kind === 10; } function shouldRescanTemplateToken(container) { - return container.kind === 12 || - container.kind === 13; + return container.kind === 13 || + container.kind === 14; } function startsWithSlashToken(t) { - return t === 37 || t === 58; + return t === 38 || t === 59; } function readTokenInfo(n) { if (!isOnToken()) { @@ -32042,7 +33209,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 26) { + if (expectedScanAction === 1 && currentToken === 27) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -32052,7 +33219,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 15) { + else if (expectedScanAction === 3 && currentToken === 16) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } @@ -32173,8 +33340,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -32317,79 +33484,90 @@ var ts; /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 77), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 101), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66, 3]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 76, 97, 82, 77]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99, 95, 89, 75, 91, 98]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 76, 77, 68]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97, 82]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120, 126]), 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122, 124]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 70, 119, 74, 78, 79, 80, 120, 103, 86, 104, 122, 123, 107, 109, 108, 126, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.FromTokens([16, 18, 26, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112, 66, 79, 74, 70, 110, 109, 107, 108, 120, 126, 18, 36])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.FromTokens([66, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111, 36]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -32415,6 +33593,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -32427,6 +33610,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -32436,32 +33620,37 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -32473,31 +33662,31 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 196; + return context.contextNode.kind === 197; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178: case 179: - case 186: - case 147: + case 180: + case 187: + case 148: return true; - case 160: - case 213: - case 218: - case 208: - case 135: - case 244: + case 161: + case 214: + case 219: + case 209: + case 136: + case 245: + case 139: case 138: - case 137: - return context.currentTokenSpan.kind === 54 || context.nextTokenSpan.kind === 54; - case 197: - return context.currentTokenSpan.kind === 87 || context.nextTokenSpan.kind === 87; + return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; case 198: - return context.currentTokenSpan.kind === 131 || context.nextTokenSpan.kind === 131; + return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; + case 199: + return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; } return false; }; @@ -32505,7 +33694,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -32546,91 +33735,91 @@ var ts; return true; } switch (node.kind) { - case 189: + case 190: + case 218: + case 163: case 217: - case 162: - case 216: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: - case 170: - case 141: + case 145: case 171: - case 212: + case 142: + case 172: + case 213: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 || context.contextNode.kind === 170; + return context.contextNode.kind === 211 || context.contextNode.kind === 171; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211: case 212: - case 214: - case 152: + case 213: case 215: + case 153: + case 216: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211: - case 215: - case 214: - case 189: - case 241: + case 212: case 216: - case 203: + case 215: + case 190: + case 242: + case 217: + case 204: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193: - case 203: - case 196: + case 194: + case 204: case 197: case 198: + case 199: + case 196: + case 207: case 195: - case 206: - case 194: - case 202: - case 241: + case 203: + case 242: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162; + return context.contextNode.kind === 163; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165; + return context.contextNode.kind === 166; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 167; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23; + return context.currentTokenSpan.kind !== 24; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -32648,52 +33837,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136; + return node.kind === 137; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 && + return context.currentTokenParent.kind === 210 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215; + return context.contextNode.kind === 216; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 153; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 && token.kind !== 26) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 148: - case 211: + case 149: + case 169: case 212: - case 210: - case 170: + case 184: + case 213: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: case 145: - case 165: + case 146: case 166: + case 167: + case 186: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 && context.currentTokenParent.kind === 174; + return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -32716,7 +33911,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 + 1; + this.mapRowLength = 132 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -32893,7 +34088,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 131; token++) { + for (var token = 0; token <= 132; token++) { result.push(token); } return result; @@ -32935,17 +34130,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(67, 131); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 65); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87, 88, 131, 113, 121]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39, 40, 48, 47]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 66, 16, 18, 14, 94, 89]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); + TokenRange.Keywords = TokenRange.FromRange(68, 132); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([66, 125, 127, 117, 128, 100, 114]); + TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -33021,6 +34216,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -33071,11 +34276,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -33123,17 +34328,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 211: case 212: + case 213: return ts.rangeContainsRange(parent.members, node); - case 215: - var body = parent.body; - return body && body.kind === 189 && ts.rangeContainsRange(body.statements, node); - case 245: - case 189: case 216: + var body = parent.body; + return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); + case 246: + case 190: + case 217: return ts.rangeContainsRange(parent.statements, node); - case 241: + case 242: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -33258,9 +34463,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 245 || - parent.kind === 238 || - parent.kind === 239) { + parent.kind === 246 || + parent.kind === 239 || + parent.kind === 240) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -33293,18 +34498,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211: return 70; - case 212: return 104; - case 210: return 84; - case 214: return 214; - case 142: return 120; - case 143: return 126; - case 140: + case 212: return 71; + case 213: return 105; + case 211: return 85; + case 215: return 215; + case 143: return 121; + case 144: return 127; + case 141: if (node.asteriskToken) { - return 36; + return 37; } - case 138: - case 135: + case 139: + case 136: return node.name.kind; } } @@ -33312,8 +34517,8 @@ var ts; return { getIndentationForComment: function (kind) { switch (kind) { - case 15: - case 19: + case 16: + case 20: return indentation + delta; } return indentation; @@ -33325,15 +34530,15 @@ var ts; } } switch (kind) { - case 14: case 15: - case 18: - case 19: case 16: + case 19: + case 20: case 17: - case 77: - case 101: - case 53: + case 18: + case 78: + case 102: + case 54: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -33413,7 +34618,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -33703,49 +34908,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189: - case 216: + case 190: + case 217: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141: - case 210: - case 170: - case 140: - case 139: + case 142: + case 211: case 171: + case 141: + case 140: + case 172: if (node.typeParameters === list) { - return 24; + return 25; } else if (node.parameters === list) { - return 16; + return 17; } break; - case 165: case 166: + case 167: if (node.typeArguments === list) { - return 24; + return 25; } else if (node.arguments === list) { - return 16; + return 17; } break; - case 148: + case 149: if (node.typeArguments === list) { - return 24; + return 25; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16: - return 17; - case 24: - return 26; + case 17: + return 18; + case 25: + return 27; } return 0; } @@ -33815,17 +35020,17 @@ var ts; if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 8 || - precedingToken.kind === 9 || + var precedingTokenIsLiteral = precedingToken.kind === 9 || precedingToken.kind === 10 || precedingToken.kind === 11 || precedingToken.kind === 12 || - precedingToken.kind === 13; + precedingToken.kind === 13 || + precedingToken.kind === 14; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 178) { + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -33923,7 +35128,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 || !parentAndChildShareLine); + (parent.kind === 246 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -33934,10 +35139,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14) { + if (nextToken.kind === 15) { return true; } - else if (nextToken.kind === 15) { + else if (nextToken.kind === 16) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -33947,8 +35152,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77, sourceFile); + if (parent.kind === 194 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -33959,23 +35164,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148: + case 149: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162: + case 163: return node.parent.properties; - case 161: + case 162: return node.parent.elements; - case 210: - case 170: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: - case 145: { + case 145: + case 146: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -33986,8 +35191,8 @@ var ts; } break; } - case 166: - case 165: { + case 167: + case 166: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -34012,11 +35217,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 17) { + if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 165 || - node.parent.kind === 166) && + if (node.parent && (node.parent.kind === 166 || + node.parent.kind === 167) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -34034,10 +35239,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165: case 166: - case 163: + case 167: case 164: + case 165: node = node.expression; break; default: @@ -34052,7 +35257,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23) { + if (list[i].kind === 24) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -34092,28 +35297,41 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211: case 212: + case 213: + case 215: case 214: - case 161: - case 189: - case 216: case 162: - case 152: - case 154: - case 217: - case 239: - case 238: - case 169: - case 165: - case 166: case 190: - case 208: - case 224: - case 201: - case 179: + case 217: + case 163: + case 153: + case 155: + case 218: + case 240: + case 239: + case 170: + case 164: + case 166: + case 167: + case 191: + case 209: + case 225: + case 202: + case 180: + case 160: case 159: + case 231: + case 140: + case 145: + case 146: + case 136: + case 150: + case 151: + case 156: case 158: + case 168: + case 176: return true; } return false; @@ -34123,22 +35341,20 @@ var ts; return true; } switch (parent) { - case 194: case 195: - case 197: - case 198: case 196: - case 193: - case 210: - case 170: - case 140: - case 139: - case 144: + case 198: + case 199: + case 197: + case 194: + case 211: case 171: case 141: + case 172: case 142: case 143: - return child !== 189; + case 144: + return child !== 190; default: return false; } @@ -34189,6 +35405,45 @@ var ts; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); var scanner = ts.createScanner(2, true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -34238,7 +35493,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268, nodes.pos, nodes.end, 4096, this); + var list = createNode(269, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -34257,7 +35512,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132) { + if (this.kind >= 133) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -34299,24 +35554,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -34358,7 +35609,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 135) { + if (canUseParsedParamTagComments && declaration.kind === 136) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -34366,13 +35617,13 @@ var ts; } }); } - if (declaration.kind === 215 && declaration.body.kind === 215) { + if (declaration.kind === 216 && declaration.body.kind === 216) { return; } - while (declaration.kind === 215 && declaration.parent.kind === 215) { + while (declaration.kind === 216 && declaration.parent.kind === 216) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -34608,6 +35859,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 | 2048) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -34677,9 +35933,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { var expr = declaration.name.expression; - if (expr.kind === 163) { + if (expr.kind === 164) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -34689,9 +35945,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -34699,9 +35955,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210: + case 211: + case 141: case 140: - case 139: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -34718,62 +35974,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 211: case 212: case 213: case 214: case 215: - case 218: - case 227: - case 223: - case 218: - case 220: - case 221: - case 142: - case 143: - case 152: - addDeclaration(node); - case 141: - case 190: - case 209: - case 158: - case 159: case 216: + case 219: + case 228: + case 224: + case 219: + case 221: + case 222: + case 143: + case 144: + case 153: + addDeclaration(node); + case 142: + case 191: + case 210: + case 159: + case 160: + case 217: ts.forEachChild(node, visit); break; - case 189: + case 190: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135: + case 136: if (!(node.flags & 112)) { break; } - case 208: - case 160: + case 209: + case 161: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244: + case 245: + case 139: case 138: - case 137: addDeclaration(node); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { addDeclaration(importClause.namedBindings); } else { @@ -34915,14 +36171,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 170) { + if (declaration.kind === 171) { return true; } - if (declaration.kind !== 208 && declaration.kind !== 210) { + if (declaration.kind !== 209 && declaration.kind !== 211) { return false; } - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { - if (parent_9.kind === 245 || parent_9.kind === 216) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + if (parent_8.kind === 246 || parent_8.kind === 217) { return false; } } @@ -35027,37 +36283,57 @@ var ts; sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); var outputText; + var sourceMapText; var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); + } program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -35112,11 +36388,12 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -35197,6 +36474,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -35212,6 +36490,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -35225,66 +36509,76 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 86) { + if (token === 120) { token = scanner.scan(); - if (token === 8) { + if (token === 123) { + token = scanner.scan(); + if (token === 9) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87) { + token = scanner.scan(); + if (token === 9) { recordModuleName(); continue; } else { - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } - else if (token === 54) { + else if (token === 55) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); - if (token === 16) { + if (token === 17) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } } } - else if (token === 23) { + else if (token === 24) { token = scanner.scan(); } else { continue; } } - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 113) { + if (token === 114) { token = scanner.scan(); - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } @@ -35293,28 +36587,28 @@ var ts; } } } - else if (token === 79) { + else if (token === 80) { token = scanner.scan(); - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } @@ -35328,12 +36622,12 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -35341,17 +36635,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 && - (node.parent.kind === 200 || node.parent.kind === 199) && + return node.kind === 67 && + (node.parent.kind === 201 || node.parent.kind === 200) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 && - node.parent.kind === 204 && + return node.kind === 67 && + node.parent.kind === 205 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -35362,55 +36656,55 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 && node.parent.right === node; + return node.parent.kind === 133 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 && node.parent.name === node; + return node.parent.kind === 216 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 && + return node.kind === 67 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 66 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 242 || node.parent.kind === 243) && node.parent.name === node; + return (node.kind === 67 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 || node.kind === 7) { + if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 138: - case 137: - case 242: - case 244: - case 140: case 139: - case 142: + case 138: + case 243: + case 245: + case 141: + case 140: case 143: - case 215: + case 144: + case 216: return node.parent.name === node; - case 164: + case 165: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8) { + if (node.kind === 9) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -35441,7 +36735,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 67; i <= 131; i++) { + for (var i = 68; i <= 132; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -35456,17 +36750,17 @@ var ts; return undefined; } switch (node.kind) { - case 245: + case 246: + case 141: case 140: - case 139: - case 210: - case 170: - case 142: - case 143: case 211: + case 171: + case 143: + case 144: case 212: - case 214: + case 213: case 215: + case 216: return node; } } @@ -35474,38 +36768,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 215: return ScriptElementKind.moduleElement; - case 211: return ScriptElementKind.classElement; - case 212: return ScriptElementKind.interfaceElement; - case 213: return ScriptElementKind.typeElement; - case 214: return ScriptElementKind.enumElement; - case 208: + case 216: return ScriptElementKind.moduleElement; + case 212: return ScriptElementKind.classElement; + case 213: return ScriptElementKind.interfaceElement; + case 214: return ScriptElementKind.typeElement; + case 215: return ScriptElementKind.enumElement; + case 209: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210: return ScriptElementKind.functionElement; - case 142: return ScriptElementKind.memberGetAccessorElement; - case 143: return ScriptElementKind.memberSetAccessorElement; + case 211: return ScriptElementKind.functionElement; + case 143: return ScriptElementKind.memberGetAccessorElement; + case 144: return ScriptElementKind.memberSetAccessorElement; + case 141: case 140: - case 139: return ScriptElementKind.memberFunctionElement; + case 139: case 138: - case 137: return ScriptElementKind.memberVariableElement; - case 146: return ScriptElementKind.indexSignatureElement; - case 145: return ScriptElementKind.constructSignatureElement; - case 144: return ScriptElementKind.callSignatureElement; - case 141: return ScriptElementKind.constructorImplementationElement; - case 134: return ScriptElementKind.typeParameterElement; - case 244: return ScriptElementKind.variableElement; - case 135: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218: - case 223: - case 220: - case 227: + case 147: return ScriptElementKind.indexSignatureElement; + case 146: return ScriptElementKind.constructSignatureElement; + case 145: return ScriptElementKind.callSignatureElement; + case 142: return ScriptElementKind.constructorImplementationElement; + case 135: return ScriptElementKind.typeParameterElement; + case 245: return ScriptElementKind.variableElement; + case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219: + case 224: case 221: + case 228: + case 222: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -35573,17 +36867,33 @@ var ts; } var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); if (program) { var oldSourceFiles = program.getSourceFiles(); for (var _i = 0; _i < oldSourceFiles.length; _i++) { @@ -35671,44 +36981,44 @@ var ts; return false; } switch (node.kind) { - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211: + case 212: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240: + case 241: var heritageClause = node; - if (heritageClause.token === 103) { + if (heritageClause.token === 104) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212: + case 213: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213: + case 214: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: - case 210: + case 211: + case 172: + case 211: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -35716,20 +37026,20 @@ var ts; return true; } break; - case 190: + case 191: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208: + case 209: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165: case 166: + case 167: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -35737,7 +37047,7 @@ var ts; return true; } break; - case 135: + case 136: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -35753,17 +37063,17 @@ var ts; return true; } break; - case 138: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168: + case 169: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136: + case 137: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -35789,17 +37099,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109: - case 107: + case 110: case 108: - case 119: + case 109: + case 120: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 110: - case 79: - case 71: - case 74: - case 112: + case 111: + case 80: + case 72: + case 75: + case 113: } } } @@ -35845,6 +37155,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -35852,8 +37163,33 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { + isJsDocTagName = true; + } + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267: + case 265: + case 266: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -35873,13 +37209,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20) { - if (parent_10.kind === 163) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21) { + if (parent_9.kind === 164) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132) { + else if (parent_9.kind === 133) { node = contextToken.parent.left; isRightOfDot = true; } @@ -35887,7 +37223,7 @@ var ts; return undefined; } } - else if (kind === 24 && sourceFile.languageVariant === 1) { + else if (kind === 25 && sourceFile.languageVariant === 1) { isRightOfOpenTag = true; location = contextToken; } @@ -35916,11 +37252,11 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 || node.kind === 132 || node.kind === 163) { + if (node.kind === 67 || node.kind === 133 || node.kind === 164) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -35966,7 +37302,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231) || (jsxContainer.kind === 232)) { + if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -36008,41 +37344,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 161 - || containingNodeKind === 178 - || containingNodeKind === 149; - case 16: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 169 - || containingNodeKind === 157; - case 18: - return containingNodeKind === 161 - || containingNodeKind === 146 - || containingNodeKind === 133; - case 122: + case 24: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 162 + || containingNodeKind === 179 + || containingNodeKind === 150; + case 17: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 170 + || containingNodeKind === 158; + case 19: + return containingNodeKind === 162 + || containingNodeKind === 147 + || containingNodeKind === 134; case 123: + case 124: return true; - case 20: - return containingNodeKind === 215; - case 14: - return containingNodeKind === 211; - case 54: - return containingNodeKind === 208 - || containingNodeKind === 178; - case 11: - return containingNodeKind === 180; + case 21: + return containingNodeKind === 216; + case 15: + return containingNodeKind === 212; + case 55: + return containingNodeKind === 209 + || containingNodeKind === 179; case 12: - return containingNodeKind === 187; - case 109: - case 107: + return containingNodeKind === 181; + case 13: + return containingNodeKind === 188; + case 110: case 108: - return containingNodeKind === 138; + case 109: + return containingNodeKind === 139; } switch (previousToken.getText()) { case "public": @@ -36054,8 +37390,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 - || contextToken.kind === 9 + if (contextToken.kind === 9 + || contextToken.kind === 10 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -36064,7 +37400,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9; + || contextToken.kind === 10; } } return false; @@ -36073,15 +37409,23 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162) { + if (objectLikeContainer.kind === 163) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158) { + else if (objectLikeContainer.kind === 159) { isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -36096,9 +37440,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 ? - 219 : - 225; + var declarationKind = namedImportsOrExports.kind === 223 ? + 220 : + 226; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -36117,11 +37461,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 || parent_11.kind === 158)) { - return parent_11; + case 15: + case 24: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + return parent_10; } break; } @@ -36131,11 +37475,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: + case 15: + case 24: switch (contextToken.parent.kind) { - case 222: - case 226: + case 223: + case 227: return contextToken.parent; } } @@ -36144,21 +37488,31 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25: - case 37: - case 66: - if (parent_12 && (parent_12.kind === 231 || parent_12.kind === 232)) { - return parent_12; + case 26: + case 38: + case 67: + case 236: + case 237: + if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + return parent_11; } break; - case 15: - if (parent_12 && - parent_12.kind === 237 && - parent_12.parent && - parent_12.parent.kind === 235) { - return parent_12.parent.parent; + case 9: + if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + return parent_11.parent; + } + break; + case 16: + if (parent_11 && + parent_11.kind === 238 && + parent_11.parent && + (parent_11.parent.kind === 236)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237) { + return parent_11.parent; } break; } @@ -36167,16 +37521,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170: case 171: - case 210: + case 172: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: case 145: case 146: + case 147: return true; } return false; @@ -36184,65 +37538,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23: - return containingNodeKind === 208 || - containingNodeKind === 209 || - containingNodeKind === 190 || - containingNodeKind === 214 || - isFunction(containingNodeKind) || - containingNodeKind === 211 || - containingNodeKind === 210 || - containingNodeKind === 212 || - containingNodeKind === 159; - case 20: - return containingNodeKind === 159; - case 52: - return containingNodeKind === 160; - case 18: - return containingNodeKind === 159; - case 16: - return containingNodeKind === 241 || - isFunction(containingNodeKind); - case 14: - return containingNodeKind === 214 || - containingNodeKind === 212 || - containingNodeKind === 152; - case 22: - return containingNodeKind === 137 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 || - contextToken.parent.parent.kind === 152); case 24: - return containingNodeKind === 211 || + return containingNodeKind === 209 || containingNodeKind === 210 || + containingNodeKind === 191 || + containingNodeKind === 215 || + isFunction(containingNodeKind) || containingNodeKind === 212 || - isFunction(containingNodeKind); - case 110: - return containingNodeKind === 138; + containingNodeKind === 184 || + containingNodeKind === 213 || + containingNodeKind === 160 || + containingNodeKind === 214; case 21: - return containingNodeKind === 135 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159); - case 109: - case 107: - case 108: - return containingNodeKind === 135; - case 113: - containingNodeKind === 223 || - containingNodeKind === 227 || - containingNodeKind === 221; - case 70: - case 78: - case 104: - case 84: - case 99: - case 120: - case 126: - case 86: - case 105: - case 71: + return containingNodeKind === 160; + case 53: + return containingNodeKind === 161; + case 19: + return containingNodeKind === 160; + case 17: + return containingNodeKind === 242 || + isFunction(containingNodeKind); + case 15: + return containingNodeKind === 215 || + containingNodeKind === 213 || + containingNodeKind === 153; + case 23: + return containingNodeKind === 138 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 213 || + contextToken.parent.parent.kind === 153); + case 25: + return containingNodeKind === 212 || + containingNodeKind === 184 || + containingNodeKind === 213 || + containingNodeKind === 214 || + isFunction(containingNodeKind); case 111: - case 129: + return containingNodeKind === 139; + case 22: + return containingNodeKind === 136 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 160); + case 110: + case 108: + case 109: + return containingNodeKind === 136; + case 114: + containingNodeKind === 224 || + containingNodeKind === 228 || + containingNodeKind === 222; + case 71: + case 79: + case 105: + case 85: + case 100: + case 121: + case 127: + case 87: + case 106: + case 72: + case 112: + case 130: return true; } switch (contextToken.getText()) { @@ -36260,7 +37616,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7) { + if (contextToken.kind === 8) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -36288,16 +37644,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 242 && - m.kind !== 243 && - m.kind !== 160) { + if (m.kind !== 243 && + m.kind !== 244 && + m.kind !== 161) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 160 && m.propertyName) { + if (m.kind === 161 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -36314,7 +37670,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235) { + if (attr.kind === 236) { seenNames[attr.name.text] = true; } } @@ -36327,8 +37683,11 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -36339,7 +37698,7 @@ var ts; } entries = getCompletionEntriesFromSymbols(symbols); } - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -36368,6 +37727,16 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { @@ -36434,7 +37803,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 183) ? + return ts.getDeclarationOfKind(symbol, 184) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -36530,14 +37899,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163) { + if (location.parent && location.parent.kind === 164) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 165 || location.kind === 166) { + if (location.kind === 166 || location.kind === 167) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -36549,7 +37918,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 || callExpression.expression.kind === 92; + var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -36564,7 +37933,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -36579,10 +37948,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -36597,21 +37966,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 118 && location.parent.kind === 141)) { + (location.kind === 119 && location.parent.kind === 142)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141) { + if (functionDeclaration.kind === 142) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -36620,11 +37989,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183)) { + if (ts.getDeclarationOfKind(symbol, 184)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(70)); + displayParts.push(ts.keywordPart(71)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -36632,74 +38001,85 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104)); + displayParts.push(ts.keywordPart(105)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(72)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78)); + displayParts.push(ts.keywordPart(79)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66; - displayParts.push(ts.keywordPart(isNamespace ? 123 : 122)); + var declaration = ts.getDeclarationOfKind(symbol, 216); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67; + displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(18)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145) { - displayParts.push(ts.keywordPart(89)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146) { + displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); + } + else { + var declaration = ts.getDeclarationOfKind(symbol, 135).parent; + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244) { + if (declaration.kind === 245) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -36707,26 +38087,26 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86)); + displayParts.push(ts.keywordPart(87)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218) { + if (declaration.kind === 219) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124)); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(125)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -36742,7 +38122,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -36800,9 +38180,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18)); return; } } @@ -36810,12 +38190,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.operatorPart(34)); + displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.operatorPart(35)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.punctuationPart(18)); } documentation = signature.getDocumentationComment(); } @@ -36840,11 +38220,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 66: - case 163: - case 132: - case 94: - case 92: + case 67: + case 164: + case 133: + case 95: + case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -36893,11 +38273,15 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 118) { + if (isNewExpressionTarget(location) || location.kind === 119) { if (symbol.flags & 32) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -36912,8 +38296,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141) || - (!selectConstructors && (d.kind === 210 || d.kind === 140 || d.kind === 139))) { + if ((selectConstructors && d.kind === 142) || + (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { declarations.push(d); if (d.body) definition = d; @@ -36964,11 +38348,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 66 && node.parent === declaration) { + if (node.kind === 67 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 243) { + if (node.parent.kind === 244) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -37039,9 +38423,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 || - node.kind === 94 || - node.kind === 92 || + if (node.kind === 67 || + node.kind === 95 || + node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -37090,77 +38474,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85: - case 77: - if (hasKind(node.parent, 193)) { + case 86: + case 78: + if (hasKind(node.parent, 194)) { return getIfElseOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 201)) { + case 92: + if (hasKind(node.parent, 202)) { return getReturnOccurrences(node.parent); } break; - case 95: - if (hasKind(node.parent, 205)) { + case 96: + if (hasKind(node.parent, 206)) { return getThrowOccurrences(node.parent); } break; - case 69: - if (hasKind(parent(parent(node)), 206)) { + case 70: + if (hasKind(parent(parent(node)), 207)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97: - case 82: - if (hasKind(parent(node), 206)) { + case 98: + case 83: + if (hasKind(parent(node), 207)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 203)) { + case 94: + if (hasKind(node.parent, 204)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68: - case 74: - if (hasKind(parent(parent(parent(node))), 203)) { + case 69: + case 75: + if (hasKind(parent(parent(parent(node))), 204)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67: - case 72: - if (hasKind(node.parent, 200) || hasKind(node.parent, 199)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68: + case 73: + if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83: - if (hasKind(node.parent, 196) || - hasKind(node.parent, 197) || - hasKind(node.parent, 198)) { + case 84: + if (hasKind(node.parent, 197) || + hasKind(node.parent, 198) || + hasKind(node.parent, 199)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101: - case 76: - if (hasKind(node.parent, 195) || hasKind(node.parent, 194)) { + case 102: + case 77: + if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118: - if (hasKind(node.parent, 141)) { + case 119: + if (hasKind(node.parent, 142)) { return getConstructorOccurrences(node.parent); } break; - case 120: - case 126: - if (hasKind(node.parent, 142) || hasKind(node.parent, 143)) { + case 121: + case 127: + if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -37172,10 +38556,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205) { + if (node.kind === 206) { statementAccumulator.push(node); } - else if (node.kind === 206) { + else if (node.kind === 207) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -37196,17 +38580,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + return parent_12; } - if (parent_13.kind === 206) { - var tryStatement = parent_13; + if (parent_12.kind === 207) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -37215,7 +38599,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 || node.kind === 199) { + if (node.kind === 201 || node.kind === 200) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -37231,15 +38615,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203: - if (statement.kind === 199) { + case 204: + if (statement.kind === 200) { continue; } - case 196: case 197: case 198: + case 199: + case 196: case 195: - case 194: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -37256,24 +38640,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 || - container.kind === 183 || - (declaration.kind === 135 && hasKind(container, 141)))) { + if (!(container.kind === 212 || + container.kind === 184 || + (declaration.kind === 136 && hasKind(container, 142)))) { return undefined; } } - else if (modifier === 110) { - if (!(container.kind === 211 || container.kind === 183)) { + else if (modifier === 111) { + if (!(container.kind === 212 || container.kind === 184)) { return undefined; } } - else if (modifier === 79 || modifier === 119) { - if (!(container.kind === 216 || container.kind === 245)) { + else if (modifier === 80 || modifier === 120) { + if (!(container.kind === 217 || container.kind === 246)) { return undefined; } } - else if (modifier === 112) { - if (!(container.kind === 211 || declaration.kind === 211)) { + else if (modifier === 113) { + if (!(container.kind === 212 || declaration.kind === 212)) { return undefined; } } @@ -37284,8 +38668,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216: - case 245: + case 217: + case 246: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -37293,15 +38677,15 @@ var ts; nodes = container.statements; } break; - case 141: + case 142: nodes = container.parameters.concat(container.parent.members); break; - case 211: - case 183: + case 212: + case 184: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -37322,19 +38706,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109: - return 16; - case 107: - return 32; - case 108: - return 64; case 110: + return 16; + case 108: + return 32; + case 109: + return 64; + case 111: return 128; - case 79: + case 80: return 1; - case 119: + case 120: return 2; - case 112: + case 113: return 256; default: ts.Debug.fail(); @@ -37354,13 +38738,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142); tryPushAccessorKeyword(accessorDeclaration.symbol, 143); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120, 126); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121, 127); }); } } } @@ -37369,18 +38753,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118); + return pushKeywordIf(keywords, token, 119); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83, 101, 76)) { - if (loopNode.kind === 194) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { + if (loopNode.kind === 195) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101)) { + if (pushKeywordIf(keywords, loopTokens[i], 102)) { break; } } @@ -37389,22 +38773,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67, 72); + pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return getLoopBreakContinueOccurrences(owner); - case 203: + case 204: return getSwitchCaseDefaultOccurrences(owner); } } @@ -37412,13 +38796,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68, 74); + pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67); + pushKeywordIf(keywords, statement.getFirstToken(), 68); } }); }); @@ -37426,13 +38810,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83); } return ts.map(keywords, getHighlightSpanForNode); } @@ -37443,50 +38827,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 189))) { + if (!(func && hasKind(func.body, 190))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 193) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85); + pushKeywordIf(keywords, children[0], 86); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77)) { + if (pushKeywordIf(keywords, children[i], 78)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193)) { + if (!hasKind(ifStatement.elseStatement, 194)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 && i < keywords.length - 1) { + if (keywords[i].kind === 78 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -37564,12 +38948,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 && + if (node.kind !== 67 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -37583,10 +38967,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94) { + if (node.kind === 95) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -37637,7 +39021,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 || declaration.kind === 227; + return declaration.kind === 224 || declaration.kind === 228; }); } function getInternedName(symbol, location, declarations) { @@ -37650,13 +39034,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 || valueDeclaration.kind === 183)) { + if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211); + return ts.getAncestor(privateDeclaration, 212); } } if (symbol.flags & 8388608) { @@ -37677,7 +39061,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 245 && !ts.isExternalModule(container)) { + if (container.kind === 246 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -37736,15 +39120,15 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 66: + case 67: return node.getWidth() === searchSymbolName.length; - case 8: + case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return node.getWidth() === searchSymbolName.length + 2; } break; - case 7: + case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -37763,8 +39147,8 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { result.push({ definition: undefined, references: [{ @@ -37809,24 +39193,12 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { @@ -37836,13 +39208,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -37855,7 +39227,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92) { + if (!node || node.kind !== 93) { return; } var container = ts.getSuperContainer(node, false); @@ -37870,32 +39242,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 139: case 138: - case 137: - case 141: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 245: + case 246: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 210: - case 170: + case 211: + case 171: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245) { + if (searchSpaceNode.kind === 246) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -37921,30 +39293,30 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94) { + if (!node || node.kind !== 95) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 170: - case 210: + case 171: + case 211: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211: + case 212: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245: - if (container.kind === 245 && !ts.isExternalModule(container)) { + case 246: + if (container.kind === 246 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -37979,11 +39351,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211) { + if (declaration.kind === 212) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212) { + else if (declaration.kind === 213) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -38081,7 +39453,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8) { + if (node.kind === 9) { start += 1; end -= 1; } @@ -38092,17 +39464,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 66 && ts.isDeclarationName(node)) { + if (node.kind === 67 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 || parent.kind === 176) { + if (parent.kind === 178 || parent.kind === 177) { return true; } - else if (parent.kind === 178 && parent.left === node) { + else if (parent.kind === 179 && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 <= operator && operator <= 65; + return 55 <= operator && operator <= 66; } } return false; @@ -38133,34 +39505,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135: - case 208: - case 160: + case 136: + case 209: + case 161: + case 139: case 138: - case 137: - case 242: case 243: case 244: - case 140: - case 139: + case 245: case 141: + case 140: case 142: case 143: - case 210: - case 170: - case 171: - case 241: - return 1; - case 134: - case 212: - case 213: - case 152: - return 2; + case 144: case 211: + case 171: + case 172: + case 242: + return 1; + case 135: + case 213: case 214: - return 1 | 2; + case 153: + return 2; + case 212: case 215: - if (node.name.kind === 8) { + return 1 | 2; + case 216: + if (node.name.kind === 9) { return 4 | 1; } else if (ts.getModuleInstanceState(node) === 1) { @@ -38169,14 +39541,14 @@ var ts; else { return 4; } - case 222: case 223: - case 218: - case 219: case 224: + case 219: + case 220: case 225: + case 226: return 1 | 2 | 4; - case 245: + case 246: return 4 | 1; } return 1 | 2 | 4; @@ -38186,8 +39558,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 || - (node.parent.kind === 185 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 || + (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -38195,47 +39567,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163) { - while (root.parent && root.parent.kind === 163) { + if (root.parent.kind === 164) { + while (root.parent && root.parent.kind === 164) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 && root.parent.parent.kind === 240) { + if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { var decl = root.parent.parent.parent; - return (decl.kind === 211 && root.parent.parent.token === 103) || - (decl.kind === 212 && root.parent.parent.token === 80); + return (decl.kind === 212 && root.parent.parent.token === 104) || + (decl.kind === 213 && root.parent.parent.token === 81); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132) { - while (root.parent && root.parent.kind === 132) { + if (root.parent.kind === 133) { + while (root.parent && root.parent.kind === 133) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 && !isLastClause; + return root.parent.kind === 149 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132) { + while (node.parent.kind === 133) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66); - if (node.parent.kind === 132 && + ts.Debug.assert(node.kind === 67); + if (node.parent.kind === 133 && node.parent.right === node && - node.parent.parent.kind === 218) { + node.parent.parent.kind === 219) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224) { + if (node.parent.kind === 225) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -38269,15 +39641,15 @@ var ts; return; } switch (node.kind) { - case 163: - case 132: - case 8: - case 81: - case 96: - case 90: - case 92: - case 94: - case 66: + case 164: + case 133: + case 9: + case 82: + case 97: + case 91: + case 93: + case 95: + case 67: break; default: return; @@ -38288,7 +39660,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 215 && + if (nodeForStartPos.parent.parent.kind === 216 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -38315,10 +39687,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -38366,7 +39738,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 && + return declaration.kind === 216 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -38375,7 +39747,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 && !ts.nodeIsMissing(node)) { + if (kind === 67 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -38462,7 +39834,7 @@ var ts; triviaScanner.setTextPos(end); continue; } - if (kind === 6) { + if (kind === 7) { var text = sourceFile.text; var ch = text.charCodeAt(start); if (ch === 60 || ch === 62) { @@ -38499,16 +39871,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 264: + case 265: processJSDocParameterTag(tag); break; - case 267: + case 268: processJSDocTemplateTag(tag); break; - case 266: + case 267: processElement(tag.typeExpression); break; - case 265: + case 266: processElement(tag.typeExpression); break; } @@ -38581,70 +39953,70 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 24 || tokenKind === 26) { + if (tokenKind === 25 || tokenKind === 27) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54) { - if (token.parent.kind === 208 || - token.parent.kind === 138 || - token.parent.kind === 135) { + if (tokenKind === 55) { + if (token.parent.kind === 209 || + token.parent.kind === 139 || + token.parent.kind === 136) { return 5; } } - if (token.parent.kind === 178 || - token.parent.kind === 176 || + if (token.parent.kind === 179 || token.parent.kind === 177 || - token.parent.kind === 179) { + token.parent.kind === 178 || + token.parent.kind === 180) { return 5; } } return 10; } - else if (tokenKind === 7) { + else if (tokenKind === 8) { return 4; } - else if (tokenKind === 8) { + else if (tokenKind === 9) { return 6; } - else if (tokenKind === 9) { + else if (tokenKind === 10) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 66) { + else if (tokenKind === 67) { if (token) { switch (token.parent.kind) { - case 211: + case 212: if (token.parent.name === token) { return 11; } return; - case 134: + case 135: if (token.parent.name === token) { return 15; } return; - case 212: + case 213: if (token.parent.name === token) { return 13; } return; - case 214: + case 215: if (token.parent.name === token) { return 12; } return; - case 215: + case 216: if (token.parent.name === token) { return 14; } return; - case 135: + case 136: if (token.parent.name === token) { return 17; } @@ -38705,14 +40077,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14: return 15; - case 16: return 17; - case 18: return 19; - case 24: return 26; - case 15: return 14; - case 17: return 16; - case 19: return 18; - case 26: return 24; + case 15: return 16; + case 17: return 18; + case 19: return 20; + case 25: return 27; + case 16: return 15; + case 18: return 17; + case 20: return 19; + case 27: return 25; } return undefined; } @@ -38747,6 +40119,38 @@ var ts; } return []; } + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + var containingFunction = ts.getAncestor(tokenAtPos, 211); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; + }, ""); + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -38813,7 +40217,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 66) { + if (node && node.kind === 67) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -38891,6 +40295,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -38910,13 +40315,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66: + case 67: nameTable[node.text] = node.text; break; + case 9: case 8: - case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 229 || + node.parent.kind === 230 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -38929,31 +40334,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 && + node.parent.kind === 165 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[66] = true; - noRegexTable[8] = true; - noRegexTable[7] = true; + noRegexTable[67] = true; noRegexTable[9] = true; - noRegexTable[94] = true; - noRegexTable[39] = true; + noRegexTable[8] = true; + noRegexTable[10] = true; + noRegexTable[95] = true; noRegexTable[40] = true; - noRegexTable[17] = true; - noRegexTable[19] = true; - noRegexTable[15] = true; - noRegexTable[96] = true; - noRegexTable[81] = true; + noRegexTable[41] = true; + noRegexTable[18] = true; + noRegexTable[20] = true; + noRegexTable[16] = true; + noRegexTable[97] = true; + noRegexTable[82] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 || - keyword2 === 126 || - keyword2 === 118 || - keyword2 === 110) { + if (keyword2 === 121 || + keyword2 === 127 || + keyword2 === 119 || + keyword2 === 111) { return true; } return false; @@ -38966,7 +40371,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -38974,8 +40379,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -39036,7 +40441,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(11); + templateStack.push(12); break; } scanner.setText(text); @@ -39048,55 +40453,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 || token === 58) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9) { - token = 9; + if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10) { + token = 10; } } - else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 66; + else if (lastNonTriviaToken === 21 && isKeyword(token)) { + token = 67; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 66; + token = 67; } - else if (lastNonTriviaToken === 66 && - token === 24) { + else if (lastNonTriviaToken === 67 && + token === 25) { angleBracketStack++; } - else if (token === 26 && angleBracketStack > 0) { + else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 114 || - token === 127 || - token === 125 || - token === 117 || - token === 128) { + else if (token === 115 || + token === 128 || + token === 126 || + token === 118 || + token === 129) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 66; + token = 67; } } - else if (token === 11) { + else if (token === 12) { templateStack.push(token); } - else if (token === 14) { + else if (token === 15) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11) { + if (lastTemplateStackToken === 12) { token = scanner.reScanTemplateToken(); - if (token === 13) { + if (token === 14) { templateStack.pop(); } else { - ts.Debug.assert(token === 12, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -39111,7 +40516,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8) { + if (token === 9) { var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; @@ -39134,10 +40539,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13) { + if (token === 14) { result.endOfLineState = 5; } - else if (token === 10) { + else if (token === 11) { result.endOfLineState = 4; } else { @@ -39145,7 +40550,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { result.endOfLineState = 6; } } @@ -39169,42 +40574,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36: case 37: case 38: - case 34: + case 39: case 35: - case 41: + case 36: case 42: case 43: - case 24: - case 26: + case 44: + case 25: case 27: case 28: - case 88: - case 87: case 29: + case 89: + case 88: case 30: case 31: case 32: - case 44: - case 46: + case 33: case 45: - case 49: + case 47: + case 46: case 50: - case 64: - case 63: + case 51: case 65: - case 60: + case 64: + case 66: case 61: case 62: - case 55: + case 63: case 56: case 57: case 58: case 59: - case 54: - case 23: + case 60: + case 55: + case 24: return true; default: return false; @@ -39212,19 +40617,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return true; default: return false; } } function isKeyword(token) { - return token >= 67 && token <= 131; + return token >= 68 && token <= 132; } function classFromKind(token) { if (isKeyword(token)) { @@ -39233,24 +40638,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 14 && token <= 65) { + else if (token >= 15 && token <= 66) { return 10; } switch (token) { - case 7: - return 4; case 8: - return 6; + return 4; case 9: + return 6; + case 10: return 7; - case 6: + case 7: case 3: case 2: return 1; case 5: case 4: return 8; - case 66: + case 67: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -39276,7 +40681,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -39366,9 +40771,11 @@ var ts; CommandNames.Format = "format"; CommandNames.Formatonkey = "formatonkey"; CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; CommandNames.NavBar = "navbar"; CommandNames.Navto = "navto"; CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; CommandNames.Open = "open"; CommandNames.Quickinfo = "quickinfo"; CommandNames.References = "references"; @@ -39378,6 +40785,7 @@ var ts; CommandNames.SignatureHelp = "signatureHelp"; CommandNames.TypeDefinition = "typeDefinition"; CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; CommandNames.Unknown = "unknown"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); var Errors; @@ -39398,57 +40806,61 @@ var ts; this.handlers = (_a = {}, _a[CommandNames.Exit] = function () { _this.exit(); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Definition] = function (request) { var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.TypeDefinition] = function (request) { var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.References] = function (request) { var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.Rename] = function (request) { var renameArgs = request.arguments; - return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings) }; + return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true }; }, _a[CommandNames.Open] = function (request) { var openArgs = request.arguments; _this.openClientFile(openArgs.file); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Quickinfo] = function (request) { var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file) }; + return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; }, _a[CommandNames.Format] = function (request) { var formatArgs = request.arguments; - return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file) }; + return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true }; }, _a[CommandNames.Formatonkey] = function (request) { var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file) }; + return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; }, _a[CommandNames.Completions] = function (request) { var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file) }; + return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; }, _a[CommandNames.CompletionDetails] = function (request) { var completionDetailsArgs = request.arguments; - return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file) }; + return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true }; }, _a[CommandNames.SignatureHelp] = function (request) { var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file) }; + return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; }, _a[CommandNames.Geterr] = function (request) { var geterrArgs = request.arguments; return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + }, _a[CommandNames.Change] = function (request) { var changeArgs = request.arguments; _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); @@ -39477,23 +40889,31 @@ var ts; }, _a[CommandNames.Navto] = function (request) { var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount) }; + return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true }; }, _a[CommandNames.Brace] = function (request) { var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file) }; + return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; }, _a[CommandNames.NavBar] = function (request) { var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file) }; + return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; }, _a[CommandNames.Occurrences] = function (request) { var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - return { response: _this.getOccurrences(line, offset, fileName) }; + return { response: _this.getOccurrences(line, offset, fileName), responseRequired: true }; + }, + _a[CommandNames.DocumentHighlights] = function (request) { + var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file, filesToSearch = _a.filesToSearch; + return { response: _this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true }; }, _a[CommandNames.ProjectInfo] = function (request) { var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList) }; + return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + }, + _a[CommandNames.ReloadProjects] = function (request) { + _this.reloadProjects(); + return { responseRequired: false }; }, _a ); @@ -39590,6 +41010,9 @@ var ts; this.syntacticCheck(file, project); this.semanticCheck(file, project); }; + Session.prototype.reloadProjects = function () { + this.projectService.reloadProjects(); + }; Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; if (ms === void 0) { ms = 1500; } @@ -39599,10 +41022,11 @@ var ts; } }, ms); }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs) { + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; if (ms === void 0) { ms = 1500; } if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } if (followMs > ms) { followMs = ms; } @@ -39617,7 +41041,7 @@ var ts; var checkOne = function () { if (matchSeq(seq)) { var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { _this.syntacticCheck(checkSpec.fileName, checkSpec.project); _this.immediateId = setImmediate(function () { _this.semanticCheck(checkSpec.fileName, checkSpec.project); @@ -39696,6 +41120,33 @@ var ts; }; }); }; + Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + if (!documentHighlights) { + return undefined; + } + return documentHighlights.map(convertToDocumentHighlightsItem); + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); + var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; Session.prototype.getProjectInfo = function (fileName, needFileNameList) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -39703,7 +41154,7 @@ var ts; configFileName: project.projectFilename }; if (needFileNameList) { - projectInfo.fileNameList = project.getFileNameList(); + projectInfo.fileNames = project.getFileNames(); } return projectInfo; }; @@ -40116,6 +41567,45 @@ var ts; end: compilerService.host.positionToLineOffset(file, span.start + span.length) }); }); }; + Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + var _this = this; + var _a = this.getProjectInfo(fileName, true), configFileName = _a.configFileName, fileNamesInProject = _a.fileNames; + fileNamesInProject = fileNamesInProject.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(normalizedFileName); + for (var _i = 0; _i < fileNamesInProject.length; _i++) { + var fileNameInProject = fileNamesInProject[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { + var normalizedFileName = ts.normalizePath(fileName); + return { fileName: normalizedFileName, project: project }; + }); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; Session.prototype.exit = function () { }; Session.prototype.addProtocolHandler = function (command, handler) { @@ -40238,12 +41728,52 @@ var ts; server.ScriptInfo = ScriptInfo; var LSHost = (function () { function LSHost(host, project) { + var _this = this; this.host = host; this.project = project; this.ls = null; this.filenameToScript = {}; this.roots = []; + this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.moduleResolutionHost = { + fileExists: function (fileName) { return _this.fileExists(fileName); }, + readFile: function (fileName) { return _this.host.readFile(fileName); } + }; } + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var newResolutions = {}; + var resolvedFileNames = []; + var compilerOptions = this.getCompilationSettings(); + for (var _i = 0; _i < moduleNames.length; _i++) { + var moduleName = moduleNames[_i]; + var resolution = ts.lookUp(newResolutions, moduleName); + if (!resolution) { + var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); + resolution.lastCheckTime = Date.now(); + newResolutions[moduleName] = resolution; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedFileNames.push(resolution.resolvedFileName); + } + this.resolvedModuleNames.set(containingFile, newResolutions); + return resolvedFileNames; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + if (resolution.resolvedFileName) { + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; LSHost.prototype.getDefaultLibFileName = function () { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); @@ -40256,6 +41786,7 @@ var ts; }; LSHost.prototype.setCompilationSettings = function (opt) { this.compilationSettings = opt; + this.resolvedModuleNames.clear(); }; LSHost.prototype.lineAffectsRefs = function (filename, line) { var info = this.getScriptInfo(filename); @@ -40283,6 +41814,7 @@ var ts; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { this.filenameToScript[info.fileName] = undefined; + this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.getScriptInfo = function (filename) { @@ -40304,6 +41836,13 @@ var ts; this.roots.push(info); } }; + LSHost.prototype.removeRoot = function (info) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + }; LSHost.prototype.saveTo = function (filename, tmpfilename) { var script = this.getScriptInfo(filename); if (script) { @@ -40410,7 +41949,7 @@ var ts; Project.prototype.openReferencedFile = function (filename) { return this.projectService.openFile(filename, false); }; - Project.prototype.getFileNameList = function () { + Project.prototype.getFileNames = function () { var sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); }; @@ -40455,6 +41994,10 @@ var ts; info.defaultProject = this; this.compilerService.host.addRoot(info); }; + Project.prototype.removeRoot = function (info) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + }; Project.prototype.filesToString = function () { var strBuilder = ""; ts.forEachValue(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); @@ -40520,6 +42063,11 @@ var ts; } } }; + ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + }; ProjectService.prototype.log = function (msg, type) { if (type === void 0) { type = "Err"; } this.psLogger.msg(msg, type); @@ -40589,6 +42137,18 @@ var ts; } this.configuredProjects = configuredProjects; }; + ProjectService.prototype.removeConfiguredProject = function (project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + var fileNames = project.getFileNames(); + for (var _i = 0; _i < fileNames.length; _i++) { + var fileName = fileNames[_i]; + var info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + }; ProjectService.prototype.setConfiguredProjectRoot = function (info) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var configuredProject = this.configuredProjects[i]; @@ -40707,11 +42267,31 @@ var ts; } return referencingProjects; }; + ProjectService.prototype.reloadProjects = function () { + for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + }; ProjectService.prototype.updateProjectStructure = function () { this.log("updating project structure from ...", "Info"); this.printProjects(); - var openFilesReferenced = []; var unattachedOpenFiles = []; + var openFileRootsConfigured = []; + for (var _i = 0, _a = this.openFileRootsConfigured; _i < _a.length; _i++) { + var info = _a[_i]; + var project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + var openFilesReferenced = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -40794,32 +42374,36 @@ var ts; return undefined; }; ProjectService.prototype.openClientFile = function (fileName) { + this.openOrUpdateConfiguredProjectForFile(fileName); + var info = this.openFile(fileName, true); + this.addOpenFile(info); + this.printProjects(); + return info; + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); this.log("Search path: " + searchPath, "Info"); var configFileName = this.findConfigFile(searchPath); if (configFileName) { this.log("Config file name: " + configFileName, "Info"); - } - else { - this.log("no config file"); - } - if (configFileName) { - configFileName = getAbsolutePath(configFileName, searchPath); - } - if (configFileName && (!this.configProjectIsActive(configFileName))) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + var project = this.findConfiguredProjectByConfigFile(configFileName); + if (!project) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } } else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); + this.updateConfiguredProject(project); } } - var info = this.openFile(fileName, true); - this.addOpenFile(info); - this.printProjects(); - return info; + else { + this.log("No config files found."); + } }; ProjectService.prototype.closeClientFile = function (filename) { var info = ts.lookUp(this.filenameToScriptInfo, filename); @@ -40888,46 +42472,105 @@ var ts; this.psLogger.endGroup(); }; ProjectService.prototype.configProjectIsActive = function (fileName) { + return this.findConfiguredProjectByConfigFile(fileName) === undefined; + }; + ProjectService.prototype.findConfiguredProjectByConfigFile = function (configFileName) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; } } - return false; + return undefined; }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + ProjectService.prototype.configFileToProjectOptions = function (configFilename) { configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); - var rawConfig = ts.readConfigFile(configFilename); + var contents = this.host.readFile(configFilename); + var rawConfig = ts.parseConfigFileText(configFilename, contents); if (rawConfig.error) { - return rawConfig.error; + return { succeeded: false, error: rawConfig.error }; } else { var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { errorMsg: "tsconfig option errors" }; + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames) { + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } }; + } + else { var projectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; - var proj = this.createProject(configFilename, projectOptions); - for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { - var rootFilename = parsedCommandLine.fileNames[i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } + return { succeeded: true, projectOptions: projectOptions }; + } + } + }; + ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + var _this = this; + var _a = this.configFileToProjectOptions(configFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; + } + else { + var proj = this.createProject(configFilename, projectOptions); + for (var i = 0, len = projectOptions.files.length; i < len; i++) { + var rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + var info = this.openFile(rootFilename, clientFileName == rootFilename); + proj.addRoot(info); } - proj.finishGraph(); - return { success: true, project: proj }; + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + proj.finishGraph(); + proj.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(proj); }); + return { success: true, project: proj }; + } + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + var oldFileNames = project.compilerService.host.roots.map(function (info) { return info.fileName; }); + var newFileNames = projectOptions.files; + var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); + var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); + for (var _i = 0; _i < fileNamesToRemove.length; _i++) { + var fileName = fileNamesToRemove[_i]; + var info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + for (var _b = 0; _b < fileNamesToAdd.length; _b++) { + var fileName = fileNamesToAdd[_b]; + var info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + } + } + project.addRoot(info); + } + project.setProjectOptions(projectOptions); + project.finishGraph(); } } }; @@ -40972,6 +42615,7 @@ var ts; InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false }; @@ -42081,9 +43725,16 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -42180,10 +43831,22 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -42279,7 +43942,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -42308,9 +43971,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -42419,7 +44079,9 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { @@ -42460,6 +44122,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { var _this = this; return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { @@ -42537,12 +44203,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -42659,4 +44333,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/bin/typescript.d.ts b/lib/typescript.d.ts similarity index 82% rename from bin/typescript.d.ts rename to lib/typescript.d.ts index ee69b9ca909..f94d24269f1 100644 --- a/bin/typescript.d.ts +++ b/lib/typescript.d.ts @@ -23,6 +23,7 @@ declare module "typescript" { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare module "typescript" { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare module "typescript" { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare module "typescript" { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare module "typescript" { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1019,11 +1025,6 @@ declare module "typescript" { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,6 +1032,7 @@ declare module "typescript" { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1054,6 +1056,7 @@ declare module "typescript" { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1198,7 +1201,7 @@ declare module "typescript" { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1218,8 +1221,6 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1292,6 +1293,10 @@ declare module "typescript" { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1304,7 @@ declare module "typescript" { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1321,7 @@ declare module "typescript" { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1330,6 +1337,7 @@ declare module "typescript" { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1375,25 @@ declare module "typescript" { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + failedLookupLocations: string[]; + } + type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface TextSpan { start: number; @@ -1448,8 +1467,11 @@ declare module "typescript" { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare module "typescript" { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1489,13 +1511,17 @@ declare module "typescript" { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare module "typescript" { - /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; + function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule; + function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare module "typescript" { function parseCommandLine(commandLine: string[]): ParsedCommandLine; @@ -1559,6 +1585,7 @@ declare module "typescript" { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1600,6 +1627,7 @@ declare module "typescript" { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1620,6 +1648,7 @@ declare module "typescript" { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1660,6 +1689,7 @@ declare module "typescript" { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1696,6 +1726,11 @@ declare module "typescript" { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1716,6 +1751,7 @@ declare module "typescript" { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1743,6 +1779,7 @@ declare module "typescript" { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1985,6 +2022,7 @@ declare module "typescript" { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2071,10 +2109,24 @@ declare module "typescript" { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/bin/typescript.js b/lib/typescript.js similarity index 81% rename from bin/typescript.js rename to lib/typescript.js index 6035d71fa2b..c1105bb262a 100644 --- a/bin/typescript.js +++ b/lib/typescript.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1318,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1495,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1724,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1759,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1800,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2101,6 +2127,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2167,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2271,6 +2298,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2350,20 +2379,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2414,11 +2435,13 @@ var ts; Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,7 +2482,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -2467,123 +2491,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2754,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2840,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2901,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2963,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3059,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3085,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3111,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3182,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3264,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3272,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3341,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3456,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3491,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3536,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3641,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3653,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3693,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3705,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3728,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3748,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3814,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3879,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3887,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3904,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3920,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3961,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +4008,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4036,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4114,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4125,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4211,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4292,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4359,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4420,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4443,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4453,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4496,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4508,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4530,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4554,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4590,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4598,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4646,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4690,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4723,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4827,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4774,12 +4852,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4928,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4912,6 +4994,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5049,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -5031,7 +5144,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5161,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5182,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5214,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5223,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5232,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5265,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5284,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5306,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5222,40 +5328,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5370,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5415,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5441,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5460,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5479,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5494,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5570,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5465,9 +5585,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5478,23 +5598,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5626,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5521,9 +5641,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5534,19 +5654,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5675,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5688,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5697,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5745,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5760,94 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5865,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5874,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5895,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5909,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5925,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5963,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5977,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +6004,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6039,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6066,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6081,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6100,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6140,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6228,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6248,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6258,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6283,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6305,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6436,7 +6571,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6583,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6600,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6612,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6623,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6728,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6759,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6776,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6806,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6822,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6833,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7150,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7168,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7213,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7235,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7263,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7554,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7590,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7741,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7784,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7938,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7972,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8039,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,16 +8102,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7969,56 +8121,56 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8180,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8205,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8215,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8242,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8271,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8281,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8142,8 +8294,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8319,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8373,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8383,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8397,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8537,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8559,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8569,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8641,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8696,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8708,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8757,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8639,34 +8791,34 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8842,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8851,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8897,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8919,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8937,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8954,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +8982,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +8990,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +9005,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +9013,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9044,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9063,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9088,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9110,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9132,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9032,18 +9184,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9203,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9252,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9274,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9302,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9332,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9349,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9390,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9419,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9439,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9448,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9457,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9465,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9499,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9519,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9548,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9567,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9590,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9600,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9611,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9624,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9657,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9675,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9683,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9693,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9718,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9731,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9744,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9773,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9781,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9800,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9812,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9836,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9883,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9931,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9941,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9969,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +10009,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10069,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10118,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10131,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10162,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10277,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10286,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10304,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10326,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10362,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10386,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10450,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10495,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10506,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10517,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10558,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10643,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10651,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10660,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10707,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,21 +10749,21 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; + return token >= 67 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -10597,21 +10771,21 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10808,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword(); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10850,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10900,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10909,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +10980,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11018,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11113,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11125,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11166,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11193,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11206,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11230,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11247,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11257,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11290,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11331,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11345,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11357,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11366,16 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11384,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11420,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11430,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11471,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11492,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11503,84 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11593,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11602,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11627,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11635,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11650,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11671,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11682,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11710,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11783,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11831,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11861,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11887,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11914,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +12008,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12019,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12062,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12073,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12097,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12195,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12206,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12232,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12098,7 +12272,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12283,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12293,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12326,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12337,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12358,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12378,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12434,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12447,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12479,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12573,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12597,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12890,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12920,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12929,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +12986,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13008,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13021,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13174,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13203,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13234,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13254,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13268,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13101,9 +13291,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13114,7 +13304,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13320,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13140,19 +13330,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13355,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13364,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13399,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13431,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13467,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13480,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13587,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13642,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13659,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13668,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13691,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13725,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13733,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13852,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13922,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13973,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +14010,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14026,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14083,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14120,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14135,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14180,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14197,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14230,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14286,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14314,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14340,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14376,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14384,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14416,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14440,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14450,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14468,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,32 +14549,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14583,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14591,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14673,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14687,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14741,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14820,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14851,71 @@ var ts; }); } } - // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, - // a new entry with that target and an associated result value of true is pushed on the stack, and the value - // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and - // all entries pushed after it are changed to false, and the value false is returned. The target object provides - // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of - // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and - // Signature instances are used to track resolution of Signature.resolvedReturnType. - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14951,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14968,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +14995,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14796,11 +15012,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,9 +15032,13 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } // No type specified and nothing can be inferred return undefined; } @@ -14851,7 +15071,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14874,7 +15094,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 /* ObjectBindingPattern */ + return pattern.kind === 159 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14896,19 +15116,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use - // the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15138,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15170,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15183,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15216,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15101,9 +15316,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15328,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15337,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15381,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15449,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15458,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15468,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15504,10 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15540,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15492,43 +15707,70 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15921,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15938,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15784,6 +16023,29 @@ var ts; } return undefined; } + // Check if a property with the given name is known anywhere in the given type. In an object + // type, a property is considered known if the object type is empty, if it has any index + // signatures, or if the property is actually declared in the type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -15791,8 +16053,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16109,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16133,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16156,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16168,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16187,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15938,7 +16216,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16276,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16290,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16319,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16344,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16379,16 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16417,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16472,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16504,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16540,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16310,7 +16589,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -16338,20 +16617,71 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of + // a target type if the the two are identical, with the exception that the source type may have null or + // undefined in places where the target type doesn't. This is by design an asymmetric relationship. + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { + return true; + } + if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -16374,29 +16704,26 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. - function getUnionType(types, noSubtypeReduction) { + // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate + // based on the structure of the types unless the noDeduplication flag is true, which is the case when + // creating a union type from a type node and when instantiating a union type. In both of those cases, + // structural deduplication has to be deferred to properly support recursive union types. For example, + // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16404,37 +16731,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16763,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16800,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16899,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16908,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16970,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16991,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +17010,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +17021,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17065,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17085,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16809,6 +17130,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17148,140 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17352,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17558,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17596,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17713,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17726,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17750,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17837,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17870,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17947,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17991,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17655,7 +18046,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18060,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18088,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18125,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18151,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18191,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18365,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18414,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18433,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18498,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18545,23 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18569,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18583,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18599,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18646,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18682,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18720,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18751,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18760,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18785,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18796,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,98 +18839,105 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* ArrowFunction */) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { @@ -18592,7 +18973,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18625,7 +19006,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +19017,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19040,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19048,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19150,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19161,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19171,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19192,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19240,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19254,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19268,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19294,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,7 +19336,7 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -18960,7 +19348,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19363,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,7 +19372,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18995,7 +19383,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19035,11 +19423,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19054,18 +19442,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19085,7 +19473,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19096,7 +19484,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19517,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19565,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19582,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19670,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19680,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19705,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19726,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19744,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19780,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19862,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19874,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19908,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19924,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19935,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +19968,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +20018,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20034,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -19656,7 +20053,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20081,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20111,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20136,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20163,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20196,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20210,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20232,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20244,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -19866,20 +20263,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20319,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20355,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20414,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20446,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20480,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20523,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20570,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20624,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20668,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20683,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20693,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20706,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20809,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20839,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20864,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20872,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20884,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20919,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +20993,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21052,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21098,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21125,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -20746,7 +21147,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,13 +21166,51 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -20791,7 +21230,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21349,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21364,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21382,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21398,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21457,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21503,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 163 /* PropertyAccessExpression */: { + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21528,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21587,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21663,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21677,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21689,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21714,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21744,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21757,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21772,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21831,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21866,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21913,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21938,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +21976,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +21988,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22034,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22045,14 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22075,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22087,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -21657,78 +22103,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22203,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22220,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22238,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22271,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22281,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22317,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22348,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -21922,7 +22368,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22376,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22425,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22507,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22045,7 +22515,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22611,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22631,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22717,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22283,7 +22753,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22764,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22848,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22865,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +22990,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23157,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,11 +23185,18 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23206,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23247,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23291,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23340,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23363,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23377,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23393,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23416,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23430,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23470,27 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23013,18 +23505,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23542,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23553,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23570,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23582,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23611,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23649,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23674,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23197,14 +23689,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23710,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23232,7 +23724,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23753,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23896,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23920,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +23963,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +23986,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -23533,7 +24025,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24037,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24058,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -23596,7 +24088,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24163,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23842,7 +24334,7 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. @@ -23890,7 +24382,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24452,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -23981,7 +24473,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24506,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24522,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24573,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24620,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24650,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24694,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24717,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24741,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24750,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24774,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24794,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24838,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24365,7 +24865,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24902,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } @@ -24422,8 +24922,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24937,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +24952,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +24961,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +24980,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +25022,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25148,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25322,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25345,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25372,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25415,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25463,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25477,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25491,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25513,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25537,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25597,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25619,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25195,11 +25711,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25730,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25745,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25764,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25792,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25841,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25856,20 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25891,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25926,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25935,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +25983,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26004,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +26016,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +26030,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25549,7 +26076,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -25559,38 +26086,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26132,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26156,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26169,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26188,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26201,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26248,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26263,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26281,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26296,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26347,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26365,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26400,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26433,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26460,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26473,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26489,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26507,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26545,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26560,21 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26606,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26618,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26627,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26142,10 +26667,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26695,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26705,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26729,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26756,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26784,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26277,7 +26802,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26812,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26839,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26848,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26865,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26889,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26918,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +26961,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +26981,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -26481,11 +27006,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +27020,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27046,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27067,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27128,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27204,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27225,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -26710,12 +27235,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27323,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27332,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27383,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27470,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27490,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27509,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27522,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27540,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27572,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27621,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27649,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27707,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27724,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27772,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27783,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27802,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27325,10 +27854,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -27368,9 +27900,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27921,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +27944,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +27954,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +27966,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +27982,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27482,7 +28014,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +28035,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28084,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28097,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28106,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -27624,17 +28156,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28184,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28198,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28224,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28251,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27733,7 +28265,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27764,13 +28296,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28318,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28343,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27824,7 +28356,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27836,12 +28368,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28392,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -27869,7 +28401,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -27879,10 +28411,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28424,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28440,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28482,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28556,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28068,11 +28598,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28626,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28135,7 +28661,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28721,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28733,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28811,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28917,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +28935,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +29007,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29043,9 @@ var ts; if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29060,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29071,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29088,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29198,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29218,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29231,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29244,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29258,7 @@ var ts; // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. @@ -28730,17 +29268,17 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { - case 8 /* StringLiteral */: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText('`', node.text, '`'); - case 11 /* TemplateHead */: - return getQuotedEscapedLiteralText('`', node.text, '${'); - case 12 /* TemplateMiddle */: - return getQuotedEscapedLiteralText('}', node.text, '${'); - case 13 /* TemplateTail */: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29295,18 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29333,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29371,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -28875,11 +29413,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29438,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29466,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29480,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28976,37 +29514,37 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29567,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,11 +29589,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29075,11 +29613,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29625,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29648,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29660,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29158,7 +29696,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29708,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29773,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,13 +29788,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -29268,17 +29808,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29293,6 +29838,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29870,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29900,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29914,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29922,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -29409,17 +29957,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +29990,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +29999,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +30019,7 @@ var ts; // then try to preserve the original shape of the object literal. // Otherwise just try to preserve the formatting. if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +30029,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30060,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30112,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30152,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30168,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30190,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30202,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30228,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30263,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30308,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30339,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30347,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30367,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30382,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30406,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30428,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30442,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30451,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30499,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30526,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30542,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) { emit(operand); return; } @@ -29990,29 +30560,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30608,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30633,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30646,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30664,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30676,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30691,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30730,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30771,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30796,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30818,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30837,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30868,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30892,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30908,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +30939,9 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. // Do not call recordTempDeclaration because we are declaring the temps // right here. Recording means they will be declared later. @@ -30380,7 +30950,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -30405,7 +30975,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30984,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +30993,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +31001,12 @@ var ts; if (ts.isBindingPattern(declaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, false, rhsIterationValue); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +31022,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, true, undefined); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31046,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31062,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31091,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31126,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31146,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31165,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31207,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31215,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31234,36 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4 /* System */) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -30677,15 +31271,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31290,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30716,7 +31310,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { + if (expr.kind !== 67 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -30731,23 +31325,23 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31350,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30779,7 +31373,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30794,8 +31388,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31399,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31416,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30857,12 +31454,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -30881,7 +31478,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31498,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31517,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31529,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31537,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31626,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31646,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31668,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31689,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31698,27 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -31130,10 +31727,25 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(node); // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -31153,10 +31765,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31787,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31802,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +31923,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31978,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +32001,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32012,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32029,7 @@ var ts; emitDetachedComments(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, true); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +32039,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32085,27 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. - if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,11 +32145,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -31546,14 +32161,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32216,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32242,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32267,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { + if (member.kind === 142 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32310,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32347,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32384,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -31845,8 +32463,8 @@ var ts; // // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32492,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit @@ -31897,7 +32515,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32548,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32583,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32607,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32625,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32654,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32703,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32741,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32756,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32771,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32794,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32813,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32826,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32836,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32235,22 +32853,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,43 +32879,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: write("void 0"); return; - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: write("Function"); return; - case 153 /* ArrayType */: - case 154 /* TupleType */: + case 154 /* ArrayType */: + case 155 /* TupleType */: write("Array"); return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: write("Boolean"); return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: write("String"); return; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: write("Number"); return; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: write("Symbol"); return; - case 148 /* TypeReference */: + case 149 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -32307,21 +32928,27 @@ var ts; } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32360,11 +32987,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +33007,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +33028,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32482,7 +33109,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33170,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32579,7 +33206,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33225,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33239,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33251,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33304,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33317,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33343,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33362,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33413,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33468,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33495,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33507,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33522,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33539,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33554,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33577,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33587,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33614,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33640,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33663,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33697,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33729,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33754,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33763,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33777,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33788,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33817,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33833,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33867,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33890,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33899,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +33914,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +33940,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +33990,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* ImportDeclaration */ - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34081,33 @@ var ts; writeLine(); for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; - // - imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34132,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34154,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34221,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34260,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34271,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,9 +34300,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34313,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34326,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33660,19 +34353,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34374,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34409,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34434,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34464,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34544,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* FalseKeyword */: return write("false"); - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 9 /* RegularExpressionLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 12 /* TemplateMiddle */: - case 13 /* TemplateTail */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,6 +34725,11 @@ var ts; } return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges, onlyPinnedOrTripleSlashComments) { // If we're removing comments, then we want to strip out all but the pinned or // triple slash comments. @@ -34024,7 +34744,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,16 +34759,16 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); } function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { // If the caller only wants pinned or triple slash comments, then always filter @@ -34056,13 +34776,23 @@ var ts; var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitTrailingComments(node) { // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitLeadingCommentsOfPosition(pos) { var leadingComments; @@ -34077,7 +34807,7 @@ var ts; leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); @@ -34107,7 +34837,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,6 +34849,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; @@ -34139,9 +34875,265 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35141,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35159,180 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function useBaseUrl(moduleName) { + // path is not rooted + // module name does not start with './' or '../' + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35398,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,7 +35435,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -34277,18 +35446,37 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34321,6 +35509,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35587,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35600,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35611,7 @@ var ts; // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34449,14 +35702,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,8 +35785,8 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); @@ -34496,22 +35794,22 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -34522,11 +35820,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35841,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35854,31 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34656,28 +35934,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -34685,17 +35963,21 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { @@ -34721,7 +36003,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,16 +36020,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { @@ -34789,6 +36077,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36172,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -34977,20 +36277,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35088,7 +36408,7 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -35172,6 +36492,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36573,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36590,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36606,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36652,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36745,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36759,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36780,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36793,8 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +36869,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +36890,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +36916,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +36925,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +36987,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +37008,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +37073,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37081,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +37129,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +37165,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37199,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -35897,7 +37220,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -35921,7 +37244,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37253,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37362,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37383,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37395,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37421,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37445,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37491,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37757,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +38054,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +38095,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +38111,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +38148,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38196,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38215,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38246,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38268,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38284,16 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38344,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38353,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38367,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38380,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38404,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38493,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38535,64 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38610,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38648,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38673,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37436,7 +38758,7 @@ var ts; return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { @@ -37450,7 +38772,7 @@ var ts; if (position <= child.end) { if (child.getStart(sourceFile) >= position) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); return candidate && findRightmostToken(candidate); } else { @@ -37460,13 +38782,13 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38802,86 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +38908,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +38943,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +38973,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +39108,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +39160,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,7 +39188,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -37848,25 +39258,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37902,7 +39312,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,7 +39322,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } @@ -38041,8 +39451,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39643,128 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Type alias declaration + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // union type + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39791,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39809,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39820,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39830,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +39879,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +39918,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +39962,98 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +40071,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +40146,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -38897,7 +40341,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40383,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40471,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40539,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40607,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40790,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,19 +40828,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } @@ -39398,8 +40852,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40867,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +40922,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +40975,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +41010,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39614,13 +41068,13 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39683,7 +41137,7 @@ var ts; // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +41146,7 @@ var ts; // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +41186,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41298,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41417,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -40013,12 +41467,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41546,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41557,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41579,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41591,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41618,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41646,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41668,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41688,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41736,41 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 156 /* UnionType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41780,20 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +41845,47 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +41935,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +41954,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +41996,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +42050,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +42067,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +42088,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +42190,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +42240,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +42293,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42343,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42419,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42431,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42441,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42463,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42528,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42732,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42758,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +42836,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +42861,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +42944,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +42990,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +42998,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +43036,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +43056,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +43095,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +43111,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +43140,42 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +43183,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43192,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +43210,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +43229,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,11 +43249,11 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } @@ -41720,13 +43268,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +43282,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43296,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43307,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43408,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43423,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43441,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43543,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43596,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43616,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // We already had a source file for this file name. Go to the registry to // ensure that we get the right up to date version of it. We need this to // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43627,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43694,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43718,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43763,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43784,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43800,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +43836,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42343,6 +43909,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +43918,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42380,13 +43979,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +43995,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42428,12 +44027,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +44061,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +44088,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +44109,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +44162,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,8 +44209,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -42624,7 +44223,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44239,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +44292,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +44317,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44335,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44348,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44384,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44404,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44483,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44528,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44538,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44565,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42956,8 +44578,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44595,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44609,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42998,18 +44624,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44685,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44717,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44781,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +44819,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -43192,7 +44828,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +44841,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +44858,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +44874,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +44893,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +44919,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +44927,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +44935,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,26 +44986,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +45026,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +45062,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +45100,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +45121,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +45131,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +45162,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +45210,7 @@ var ts; var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +45219,24 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; } function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +45244,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +45274,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +45305,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +45348,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +45362,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45388,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45441,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45527,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45558,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45579,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45595,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45623,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45652,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45662,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45693,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45725,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45740,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45761,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45784,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45799,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +45816,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +45830,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +45868,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +45935,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +45950,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +45958,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +45976,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +46039,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +46066,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +46099,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -44471,12 +46127,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +46170,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +46203,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +46256,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +46291,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +46306,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -44698,7 +46339,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46365,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46444,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46480,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { @@ -44854,7 +46495,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46571,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46583,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46625,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46661,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46679,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46688,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46771,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46793,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // If this is name of a module declarations, check if this is right side of dotted module name - // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of + // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +46829,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +46893,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +46903,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +46964,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +46996,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +47040,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +47048,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +47092,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +47128,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. function classifyTokenType(tokenKind, token) { @@ -45496,7 +47137,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -45505,30 +47146,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +47177,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +47271,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +47313,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47403,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47425,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47470,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47504,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47584,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47605,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47628,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47675,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47697,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47706,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47777,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47796,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +47887,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +47913,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +47924,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +47935,8 @@ var ts; return; } if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of // the original text. start += offset; } @@ -46251,42 +47954,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +47997,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +48018,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +48067,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +48137,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +48302,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +48361,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48384,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48403,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48423,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48437,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48469,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48479,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48500,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48581,18 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48700,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +48826,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +48859,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +48995,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +49046,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +49133,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +49270,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/bin/typescriptServices.d.ts b/lib/typescriptServices.d.ts similarity index 82% rename from bin/typescriptServices.d.ts rename to lib/typescriptServices.d.ts index 9840a5e688f..812305c8a68 100644 --- a/bin/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -23,6 +23,7 @@ declare namespace ts { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare namespace ts { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare namespace ts { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare namespace ts { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare namespace ts { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1019,11 +1025,6 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,6 +1032,7 @@ declare namespace ts { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1054,6 +1056,7 @@ declare namespace ts { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1198,7 +1201,7 @@ declare namespace ts { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1218,8 +1221,6 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1292,6 +1293,10 @@ declare namespace ts { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1304,7 @@ declare namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1321,7 @@ declare namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1330,6 +1337,7 @@ declare namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1375,25 @@ declare namespace ts { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + failedLookupLocations: string[]; + } + type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface TextSpan { start: number; @@ -1448,8 +1467,11 @@ declare namespace ts { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1489,13 +1511,17 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { - /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; + function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule; + function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { function parseCommandLine(commandLine: string[]): ParsedCommandLine; @@ -1559,6 +1585,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1600,6 +1627,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1620,6 +1648,7 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1660,6 +1689,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1696,6 +1726,11 @@ declare namespace ts { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1716,6 +1751,7 @@ declare namespace ts { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1743,6 +1779,7 @@ declare namespace ts { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1985,6 +2022,7 @@ declare namespace ts { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2071,10 +2109,24 @@ declare namespace ts { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/bin/typescriptServices.js b/lib/typescriptServices.js similarity index 81% rename from bin/typescriptServices.js rename to lib/typescriptServices.js index 6035d71fa2b..c1105bb262a 100644 --- a/bin/typescriptServices.js +++ b/lib/typescriptServices.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1318,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1495,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1724,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1759,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1800,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2101,6 +2127,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2167,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2271,6 +2298,8 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2350,20 +2379,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2414,11 +2435,13 @@ var ts; Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,7 +2482,8 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// @@ -2467,123 +2491,123 @@ var ts; var ts; (function (ts) { var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2754,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2840,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2901,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2963,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3059,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3085,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3111,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3182,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3264,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3272,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3341,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3456,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3491,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3536,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3641,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3653,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3693,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3705,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3728,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3748,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3814,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3879,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3887,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3904,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3920,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3961,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +4008,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4036,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4114,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4125,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4211,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4292,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4359,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4420,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4443,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4453,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4496,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4508,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4530,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4554,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4590,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4598,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4646,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4690,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4723,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4827,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4774,12 +4852,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4928,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4912,6 +4994,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModuleName(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModuleName = hasResolvedModuleName; + function getResolvedModuleFileName(sourceFile, moduleNameText) { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModuleFileName = getResolvedModuleFileName; + function setResolvedModuleName(sourceFile, moduleNameText, resolvedFileName) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + ts.setResolvedModuleName = setResolvedModuleName; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5049,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -5031,7 +5144,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5161,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5182,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5214,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5223,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5232,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5265,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5284,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5306,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5222,40 +5328,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5370,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5415,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5441,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5460,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5479,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5494,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5570,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5465,9 +5585,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5478,23 +5598,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5626,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5521,9 +5641,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5534,19 +5654,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5675,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5688,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5697,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5745,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5760,94 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5865,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5874,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5895,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5909,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5925,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5963,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5977,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +6004,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6039,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6066,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6081,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6100,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6140,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6228,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6248,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6258,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6283,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6305,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6436,7 +6571,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6583,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6600,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6612,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6623,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6728,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6759,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6776,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6806,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6822,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6833,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7150,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7168,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7213,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7235,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7263,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7554,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7590,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7741,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7784,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7938,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7972,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8039,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,16 +8102,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7969,56 +8121,56 @@ var ts; } function isLiteralPropertyName() { return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8180,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8205,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8215,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8242,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8271,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8281,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8142,8 +8294,8 @@ var ts; return isIdentifierOrKeyword(); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8319,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8373,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8383,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8397,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8537,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8559,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8569,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8641,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8696,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8708,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8757,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8639,34 +8791,34 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8842,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8851,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8897,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8919,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8937,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8954,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +8982,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +8990,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +9005,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +9013,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9044,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9063,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9088,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9110,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9132,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9032,18 +9184,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9203,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9252,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9274,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9302,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9332,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9349,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9390,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9419,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9439,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9448,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9457,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9465,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9499,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9519,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9548,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9567,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9590,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9600,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9611,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9624,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9657,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9675,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9683,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9693,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9718,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9731,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9744,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9773,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9781,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9800,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9812,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9836,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9883,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9931,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9941,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9969,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +10009,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10069,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10118,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10131,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10162,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10277,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10286,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10304,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10326,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10362,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10386,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10450,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10495,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10506,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10517,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10558,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10643,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10651,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10660,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10707,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,21 +10749,21 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; + return token >= 67 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); @@ -10597,21 +10771,21 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10808,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword(); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10850,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10900,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10909,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +10980,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11018,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11113,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11125,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11166,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11193,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11206,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11230,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11247,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11257,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11290,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11331,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11345,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11357,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11192,16 +11366,16 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11384,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11420,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11430,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11471,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11492,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11503,84 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11593,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11602,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11627,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11635,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11650,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11671,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11682,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11710,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11783,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11831,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11861,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11887,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11914,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +12008,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12019,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12062,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12073,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12097,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12195,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12206,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12232,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12098,7 +12272,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12283,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12293,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12326,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12337,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12358,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12378,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12434,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12447,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12479,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12573,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12597,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12890,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12920,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12929,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +12986,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13008,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13021,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13174,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13203,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13234,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13254,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13268,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13101,9 +13291,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13114,7 +13304,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13320,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13140,19 +13330,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13355,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13364,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13399,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13431,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13467,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13480,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13587,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13642,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13659,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13668,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13691,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13725,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13733,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (!moduleName) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var fileName = ts.getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13852,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13922,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13973,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +14010,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14026,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14083,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14120,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14135,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14180,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14197,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14230,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14286,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14314,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14340,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14376,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14384,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14416,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14440,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14450,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14468,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,32 +14549,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14583,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14591,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14673,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14687,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14741,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14820,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14851,71 @@ var ts; }); } } - // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, - // a new entry with that target and an associated result value of true is pushed on the stack, and the value - // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and - // all entries pushed after it are changed to false, and the value false is returned. The target object provides - // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of - // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and - // Signature instances are used to track resolution of Signature.resolvedReturnType. - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14951,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14968,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +14995,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14796,11 +15012,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,9 +15032,13 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } // No type specified and nothing can be inferred return undefined; } @@ -14851,7 +15071,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14874,7 +15094,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 /* ObjectBindingPattern */ + return pattern.kind === 159 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14896,19 +15116,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use - // the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15138,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15170,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15183,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15216,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15101,9 +15316,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15328,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15337,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15381,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15449,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15458,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15468,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15504,10 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15540,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15492,43 +15707,70 @@ var ts; addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15921,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15938,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15784,6 +16023,29 @@ var ts; } return undefined; } + // Check if a property with the given name is known anywhere in the given type. In an object + // type, a property is considered known if the object type is empty, if it has any index + // signatures, or if the property is actually declared in the type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } function getSignaturesOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); @@ -15791,8 +16053,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16109,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16133,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16156,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16168,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16187,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15938,7 +16216,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16276,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16290,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16319,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16344,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16379,16 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16417,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16472,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16504,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16540,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16310,7 +16589,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -16338,20 +16617,71 @@ var ts; addTypeToSet(typeSet, type, typeSetKind); } } - function isSubtypeOfAny(candidate, types) { + function isObjectLiteralTypeDuplicateOf(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + var targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (var _i = 0; _i < sourceProperties.length; _i++) { + var sourceProp = sourceProperties[_i]; + var targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + function isTupleTypeDuplicateOf(source, target) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of + // a target type if the the two are identical, with the exception that the source type may have null or + // undefined in places where the target type doesn't. This is by design an asymmetric relationship. + function isTypeDuplicateOf(source, target) { + if (source === target) { + return true; + } + if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) { + return true; + } + if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + function isTypeDuplicateOfSomeType(candidate, types) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types) { + function removeDuplicateTypes(types) { var i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } @@ -16374,29 +16704,26 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. - function getUnionType(types, noSubtypeReduction) { + // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate + // based on the structure of the types unless the noDeduplication flag is true, which is the case when + // creating a union type from a type node and when instantiating a union type. In both of those cases, + // structural deduplication has to be deferred to properly support recursive union types. For example, + // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. + function getUnionType(types, noDeduplication) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -16404,37 +16731,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16763,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16800,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16899,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16908,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16970,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16991,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +17010,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +17021,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17065,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17085,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16809,6 +17130,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17148,140 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + source = getRegularTypeOfObjectLiteral(source); } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17352,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17558,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17596,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */); + var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17713,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17726,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17750,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17837,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17870,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17947,23 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17991,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17655,7 +18046,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18060,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18088,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18125,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18151,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18191,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18365,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18414,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18433,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18498,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18545,23 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18569,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18583,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18599,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18646,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18682,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18720,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18751,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18760,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18785,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18796,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,98 +18839,105 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* ArrowFunction */) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { @@ -18592,7 +18973,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -18625,7 +19006,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +19017,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19040,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19048,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19150,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19161,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19171,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19192,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19240,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19254,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19268,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19294,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,7 +19336,7 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -18960,7 +19348,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19363,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,7 +19372,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18995,7 +19383,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19035,11 +19423,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19054,18 +19442,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -19085,7 +19473,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19096,7 +19484,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19517,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19565,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19582,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19670,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19680,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19705,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19726,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19744,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19780,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19862,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19874,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19908,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19924,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19935,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +19968,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +20018,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20034,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -19656,7 +20053,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20081,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20111,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20136,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20163,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20196,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20210,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20232,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20244,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -19866,20 +20263,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20319,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20355,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20414,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20446,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20480,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20523,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20570,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20624,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20668,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20683,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20693,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20706,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20809,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20839,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20864,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20872,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20884,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20919,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +20993,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21052,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21098,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21125,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -20746,7 +21147,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,13 +21166,51 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { @@ -20791,7 +21230,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21349,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21364,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21382,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21398,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21457,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21503,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 163 /* PropertyAccessExpression */: { + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21528,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21587,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21663,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21677,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21689,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21714,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21744,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21757,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21772,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21831,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21866,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21913,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21938,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +21976,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +21988,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22034,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22045,14 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22075,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22087,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -21657,78 +22103,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22203,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22220,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22238,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22271,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22281,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22317,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22348,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -21922,7 +22368,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22376,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22425,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22507,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22045,7 +22515,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22611,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22631,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22717,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22283,7 +22753,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22764,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22848,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22865,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +22990,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23157,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,11 +23185,18 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23206,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23247,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23291,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23340,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23363,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23377,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23393,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23416,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23430,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23470,27 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23013,18 +23505,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23542,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23553,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23570,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23582,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23611,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23649,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23674,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23197,14 +23689,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23710,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23232,7 +23724,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23753,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23896,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23920,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +23963,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +23986,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -23533,7 +24025,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24037,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24058,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -23596,7 +24088,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24163,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23842,7 +24334,7 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. @@ -23890,7 +24382,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24452,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -23981,7 +24473,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24506,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24522,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24573,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24620,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24650,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24694,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24717,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24741,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24750,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24774,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24794,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24838,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24365,7 +24865,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24902,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } @@ -24422,8 +24922,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24937,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +24952,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +24961,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +24980,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +25022,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25148,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25322,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25345,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25372,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25415,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25463,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25477,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25491,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25513,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25537,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25597,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25619,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25195,11 +25711,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25730,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25745,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25764,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25792,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25841,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25856,20 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25891,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25926,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25935,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +25983,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26004,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +26016,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +26030,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25549,7 +26076,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -25559,38 +26086,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26132,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26156,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26169,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26188,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26201,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26248,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26263,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26281,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26296,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26347,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26365,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26400,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26433,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26460,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26473,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26489,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26507,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26545,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26560,21 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26606,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26618,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26627,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26142,10 +26667,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26695,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26705,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26729,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26756,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26784,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26277,7 +26802,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26812,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26839,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26848,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26865,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26889,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26918,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +26961,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +26981,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -26481,11 +27006,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +27020,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27046,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27067,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27128,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27204,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27225,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -26710,12 +27235,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27323,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27332,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27383,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27470,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27490,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27509,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27522,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27540,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27572,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27621,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27649,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27707,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27724,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27772,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27783,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27802,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27325,10 +27854,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -27368,9 +27900,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27921,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +27944,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +27954,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +27966,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +27982,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27482,7 +28014,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +28035,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28084,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28097,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28106,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -27624,17 +28156,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28184,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28198,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28224,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28251,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27733,7 +28265,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27764,13 +28296,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28318,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28343,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27824,7 +28356,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27836,12 +28368,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28392,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -27869,7 +28401,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -27879,10 +28411,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28424,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28440,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28482,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28556,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28068,11 +28598,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28626,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28135,7 +28661,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28721,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28733,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28811,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28917,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +28935,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +29007,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29043,9 @@ var ts; if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29060,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29071,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29088,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29198,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29218,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29231,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29244,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29258,7 @@ var ts; // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. @@ -28730,17 +29268,17 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { - case 8 /* StringLiteral */: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText('`', node.text, '`'); - case 11 /* TemplateHead */: - return getQuotedEscapedLiteralText('`', node.text, '${'); - case 12 /* TemplateMiddle */: - return getQuotedEscapedLiteralText('}', node.text, '${'); - case 13 /* TemplateTail */: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29295,18 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29333,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29371,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -28875,11 +29413,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29438,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29466,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29480,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28976,37 +29514,37 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { write("React.__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29567,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,11 +29589,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -29075,11 +29613,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29625,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29648,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29660,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29158,7 +29696,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29708,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29773,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,13 +29788,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -29268,17 +29808,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29293,6 +29838,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29870,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29900,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29914,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +29922,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -29409,17 +29957,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +29990,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +29999,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +30019,7 @@ var ts; // then try to preserve the original shape of the object literal. // Otherwise just try to preserve the formatting. if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +30029,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30060,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30112,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30152,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30168,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30190,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30202,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30228,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30263,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30308,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30339,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30347,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30367,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30382,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30406,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30428,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30442,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30451,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30499,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30526,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30542,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) { emit(operand); return; } @@ -29990,29 +30560,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30608,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30633,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30646,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30664,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30676,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30691,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30730,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30771,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30796,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30818,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30837,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30868,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30892,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30908,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +30939,9 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. // Do not call recordTempDeclaration because we are declaring the temps // right here. Recording means they will be declared later. @@ -30380,7 +30950,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -30405,7 +30975,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +30984,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +30993,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +31001,12 @@ var ts; if (ts.isBindingPattern(declaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, false, rhsIterationValue); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +31022,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, true, undefined); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31046,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31062,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31091,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31126,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31146,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31165,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31207,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31215,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31234,36 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4 /* System */) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -30677,15 +31271,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31290,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30716,7 +31310,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { + if (expr.kind !== 67 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -30731,23 +31325,23 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31350,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30779,7 +31373,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30794,8 +31388,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31399,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31416,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30857,12 +31454,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -30881,7 +31478,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31498,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31517,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31529,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31537,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31626,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31646,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31668,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31689,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,27 +31698,27 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -31130,10 +31727,25 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(node); // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -31153,10 +31765,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31787,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31802,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +31923,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +31978,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +32001,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32012,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32029,7 @@ var ts; emitDetachedComments(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, true); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +32039,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32085,27 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. - if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,11 +32145,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -31546,14 +32161,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32216,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32242,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32267,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { + if (member.kind === 142 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32310,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32347,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32384,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -31845,8 +32463,8 @@ var ts; // // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32492,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit @@ -31897,7 +32515,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32548,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32583,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32607,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32625,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32654,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32703,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32741,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32756,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32771,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32794,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32813,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32826,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32836,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32235,22 +32853,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,43 +32879,46 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { + if (!node) { + return; + } switch (node.kind) { - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: write("void 0"); return; - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: write("Function"); return; - case 153 /* ArrayType */: - case 154 /* TupleType */: + case 154 /* ArrayType */: + case 155 /* TupleType */: write("Array"); return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: write("Boolean"); return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: write("String"); return; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: write("Number"); return; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: write("Symbol"); return; - case 148 /* TypeReference */: + case 149 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -32307,21 +32928,27 @@ var ts; } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32360,11 +32987,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +33007,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +33028,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32482,7 +33109,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33170,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32579,7 +33206,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33225,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33239,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33251,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33304,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33317,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33343,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33362,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33413,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33468,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33495,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33507,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33522,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33539,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33554,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33577,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33587,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33614,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33640,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33663,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33697,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33729,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33754,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33763,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33777,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33788,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33817,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33833,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33867,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33890,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33899,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +33914,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +33940,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +33990,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* ImportDeclaration */ - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34081,33 @@ var ts; writeLine(); for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; - // - imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34132,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34154,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34221,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34260,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34271,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,9 +34300,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34313,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34326,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33660,19 +34353,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34374,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34409,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34434,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34464,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34544,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* FalseKeyword */: return write("false"); - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 9 /* RegularExpressionLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 12 /* TemplateMiddle */: - case 13 /* TemplateTail */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,6 +34725,11 @@ var ts; } return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges, onlyPinnedOrTripleSlashComments) { // If we're removing comments, then we want to strip out all but the pinned or // triple slash comments. @@ -34024,7 +34744,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,16 +34759,16 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); } function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { // If the caller only wants pinned or triple slash comments, then always filter @@ -34056,13 +34776,23 @@ var ts; var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitTrailingComments(node) { // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); + } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitLeadingCommentsOfPosition(pos) { var leadingComments; @@ -34077,7 +34807,7 @@ var ts; leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); @@ -34107,7 +34837,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,6 +34849,12 @@ var ts; } } } + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; @@ -34139,9 +34875,265 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35141,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.6.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35159,180 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName: resolvedFileName, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + } + function baseUrlModuleNameResolver(moduleName, containingFile, baseUrl, host) { + ts.Debug.assert(baseUrl !== undefined); + var normalizedModuleName = ts.normalizeSlashes(moduleName); + var basePart = useBaseUrl(moduleName) ? baseUrl : ts.getDirectoryPath(containingFile); + var candidate = ts.normalizePath(ts.combinePaths(basePart, moduleName)); + var failedLookupLocations = []; + return ts.forEach(ts.supportedExtensions, function (ext) { return tryLoadFile(candidate + ext); }) || { resolvedFileName: undefined, failedLookupLocations: failedLookupLocations }; + function tryLoadFile(location) { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations: failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + ts.baseUrlModuleNameResolver = baseUrlModuleNameResolver; + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function useBaseUrl(moduleName) { + // path is not rooted + // module name does not start with './' or '../' + return ts.getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return { resolvedFileName: referencedSourceFile, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35398,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,7 +35435,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; var diagnostics = ts.createDiagnosticCollection(); @@ -34277,18 +35446,37 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames || + (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedFileName; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34321,6 +35509,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var oldResolution = ts.getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35587,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35600,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35611,7 @@ var ts; // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34449,14 +35702,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,8 +35785,8 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); @@ -34496,22 +35794,22 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); @@ -34522,11 +35820,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35841,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35854,31 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34656,28 +35934,28 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { @@ -34685,17 +35963,21 @@ var ts; diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { @@ -34721,7 +36003,7 @@ var ts; if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,16 +36020,22 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { @@ -34789,6 +36077,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36172,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -34977,20 +36277,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + experimental: true, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35088,7 +36408,7 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { - var text = ''; + var text = ""; try { text = ts.sys.readFile(fileName); } @@ -35172,6 +36492,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36573,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36590,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36606,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36652,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36745,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36759,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36780,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36793,8 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +36869,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +36890,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +36916,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +36925,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +36987,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +37008,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +37073,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37081,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +37129,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +37165,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37199,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -35897,7 +37220,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that @@ -35921,7 +37244,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37253,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37362,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37383,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37395,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37421,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37445,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37491,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37757,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +38054,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +38095,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +38111,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +38148,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38196,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38215,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38246,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38268,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38284,16 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38344,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38353,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38367,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38380,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38404,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38493,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38535,64 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38610,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38648,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38673,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37436,7 +38758,7 @@ var ts; return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { @@ -37450,7 +38772,7 @@ var ts; if (position <= child.end) { if (child.getStart(sourceFile) >= position) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); return candidate && findRightmostToken(candidate); } else { @@ -37460,13 +38782,13 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38802,86 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +38908,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +38943,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +38973,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +39108,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +39160,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,7 +39188,7 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -37848,25 +39258,25 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37902,7 +39312,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,7 +39322,7 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } @@ -38041,8 +39451,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39643,128 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Type alias declaration + this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // union type + this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39791,11 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39809,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39820,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39830,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +39879,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +39918,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +39962,98 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +40071,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +40146,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -38897,7 +40341,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40383,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40471,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40539,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40607,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40790,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,19 +40828,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } @@ -39398,8 +40852,8 @@ var ts; // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: return indentation + delta; } return indentation; @@ -39413,15 +40867,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +40922,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +40975,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +41010,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39614,13 +41068,13 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39683,7 +41137,7 @@ var ts; // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +41146,7 @@ var ts; // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +41186,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41298,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41417,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -40013,12 +41467,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41546,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41557,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41579,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41591,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41618,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41646,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41668,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41688,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41736,41 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 156 /* UnionType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41780,20 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +41845,47 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +41935,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +41954,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +41996,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +42050,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +42067,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +42088,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +42190,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +42240,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +42293,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42343,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42419,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42431,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42441,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42463,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42528,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42732,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42758,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +42836,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +42861,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +42944,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +42990,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +42998,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +43036,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +43056,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +43095,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +43111,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41603,31 +43140,42 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +43183,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43192,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +43210,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +43229,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,11 +43249,11 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } @@ -41720,13 +43268,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +43282,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43296,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43307,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43408,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43423,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43441,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43543,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + // Release any files we have acquired in the old program but are // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43596,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43616,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // We already had a source file for this file name. Go to the registry to // ensure that we get the right up to date version of it. We need this to // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43627,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43694,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43718,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43763,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43784,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43800,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +43836,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42343,6 +43909,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +43918,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42380,13 +43979,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +43995,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42428,12 +44027,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +44061,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +44088,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +44109,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +44162,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,8 +44209,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -42624,7 +44223,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44239,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +44292,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +44317,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44335,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44348,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44384,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44404,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44483,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44528,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44538,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44565,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42956,8 +44578,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44595,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44609,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42998,18 +44624,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44685,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44717,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44781,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +44819,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -43192,7 +44828,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +44841,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +44858,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +44874,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +44893,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +44919,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +44927,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +44935,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,26 +44986,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +45026,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +45062,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +45100,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +45121,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +45131,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +45162,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +45210,7 @@ var ts; var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +45219,24 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; } function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +45244,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +45274,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +45305,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +45348,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +45362,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45388,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45441,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45527,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45558,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45579,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45595,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45623,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45652,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45662,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45693,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45725,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45740,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45761,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45784,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45799,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +45816,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +45830,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +45868,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +45935,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +45950,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +45958,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +45976,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +46039,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +46066,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +46099,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -44471,12 +46127,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +46170,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +46203,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +46256,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +46291,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +46306,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -44698,7 +46339,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46365,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46444,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46480,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { @@ -44854,7 +46495,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46571,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46583,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46625,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46661,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46679,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46688,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46771,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46793,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // If this is name of a module declarations, check if this is right side of dotted module name - // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of + // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +46829,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +46893,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +46903,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +46964,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +46996,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +47040,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +47048,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +47092,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +47128,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. function classifyTokenType(tokenKind, token) { @@ -45496,7 +47137,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -45505,30 +47146,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +47177,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +47271,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +47313,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47403,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47425,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47470,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47504,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47584,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47605,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47628,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47675,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47697,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47706,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47777,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47796,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +47887,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +47913,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +47924,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +47935,8 @@ var ts; return; } if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of // the original text. start += offset; } @@ -46251,42 +47954,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +47997,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +48018,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +48067,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +48137,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +48302,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +48361,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48384,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48403,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48423,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48437,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48469,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48479,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48500,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48581,18 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { return ts.lookUp(resolutionsInFile, name); }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48700,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +48826,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +48859,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +48995,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +49046,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +49133,20 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +49270,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/package.json b/package.json index c8b30f9de1c..b743b04838d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.6.0", + "version": "1.7.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ @@ -19,8 +19,8 @@ "type": "git", "url": "https://github.com/Microsoft/TypeScript.git" }, - "preferGlobal": true, - "main": "./bin/typescript.js", + "main": "./lib/typescript.js", + "typings": "./lib/typescript.d.ts", "bin": { "tsc": "./bin/tsc", "tsserver": "./bin/tsserver" @@ -38,6 +38,17 @@ "tslint": "latest" }, "scripts": { - "test": "jake runtests" + "pretest": "jake tests", + "test": "jake runtests", + "build": "npm run build:compiler && npm run build:tests", + "build:compiler": "jake local", + "build:tests": "jake tests", + "clean": "jake clean" + }, + "browser": { + "buffer": false, + "fs": false, + "os": false, + "path": false } } diff --git a/scripts/processTypes.ts b/scripts/processTypes.ts index a7e2ddfba44..0ba68803e7d 100644 --- a/scripts/processTypes.ts +++ b/scripts/processTypes.ts @@ -1480,7 +1480,7 @@ class KindAnnotation extends Annotation { public kind: SyntaxKind; public kindSymbol: Symbol; public options: KindOptions; - constructor([{ value, symbol }, { create = true, update = true, test = true } = {}, ..._arguments]: [EnumValue, KindOptions, any]) { + constructor([{ value, symbol }, { create = true, update = true, test = true } = {}, ..._arguments]: [EnumValue, KindOptions, any]) { super(_arguments); this.kind = value; this.kindSymbol = symbol; diff --git a/scripts/typescript-internal.d.ts b/scripts/typescript-internal.d.ts index ad4dd8bd6c9..edfc07b05cc 100644 --- a/scripts/typescript-internal.d.ts +++ b/scripts/typescript-internal.d.ts @@ -1,4 +1,4 @@ -/// +/// import { SourceFile, Node, Map, Symbol } from "typescript"; export * from "typescript"; diff --git a/scripts/typescript-internal.js b/scripts/typescript-internal.js index a79aec7d4f4..709e3ce7462 100644 --- a/scripts/typescript-internal.js +++ b/scripts/typescript-internal.js @@ -1 +1 @@ -module.exports = require("../bin/typescript"); \ No newline at end of file +module.exports = require("../lib/typescript"); \ No newline at end of file diff --git a/scripts/word2md.js b/scripts/word2md.js index 0645acbb143..e80275d5b2d 100644 --- a/scripts/word2md.js +++ b/scripts/word2md.js @@ -1,8 +1,16 @@ +// word2md - Word to Markdown conversion tool +// +// word2md converts a Microsoft Word document to Markdown formatted text. The tool uses the +// Word Automation APIs to start an instance of Word and access the contents of the document +// being converted. The tool must be run using the cscript.exe script host and requires Word +// to be installed on the target machine. The name of the document to convert must be specified +// as a command line argument and the resulting Markdown is written to standard output. The +// tool recognizes the specific Word styles used in the TypeScript Language Specification. var sys = (function () { var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; + fileStream.Type = 2 /*text*/; var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; + binaryStream.Type = 1 /*binary*/; var args = []; for (var i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); @@ -17,11 +25,13 @@ var sys = (function () { fileStream.Open(); binaryStream.Open(); try { + // Write characters in UTF-8 encoding fileStream.Charset = "utf-8"; fileStream.WriteText(data); + // We don't want the BOM, skip it by setting the starting location to 3 (size of BOM). fileStream.Position = 3; fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); + binaryStream.SaveToFile(fileName, 2 /*overwrite*/); } finally { binaryStream.Close(); @@ -59,6 +69,17 @@ function convertDocumentToMarkdown(doc) { setProperties(replace, replaceOptions); find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2); } + function fixHyperlinks() { + var count = doc.hyperlinks.count; + for (var i = 0; i < count; i++) { + var hyperlink = doc.hyperlinks.item(i + 1); + var address = hyperlink.address; + if (address && address.length > 0) { + var textToDisplay = hyperlink.textToDisplay; + hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")"; + } + } + } function write(s) { result += s; } @@ -184,14 +205,15 @@ function convertDocumentToMarkdown(doc) { findReplace("<", { style: "Code Fragment" }, "<", {}); findReplace("<", { style: "Terminal" }, "<", {}); findReplace("", { font: { subscript: true } }, "^&", { font: { subscript: false } }); - findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 }); - findReplace("", { style: "Production" }, "*^&*", { style: -66 }); - findReplace("", { style: "Terminal" }, "`^&`", { style: -66 }); + findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ }); + findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */ }); + findReplace("", { style: "Terminal" }, "`^&`", { style: -66 /* default font */ }); findReplace("", { font: { bold: true, italic: true } }, "***^&***", { font: { bold: false, italic: false } }); findReplace("", { font: { italic: true } }, "*^&*", { font: { italic: false } }); doc.fields.toggleShowCodes(); findReplace("^19 REF", {}, "[^&](#^&)", {}); doc.fields.toggleShowCodes(); + fixHyperlinks(); writeDocument(); result = result.replace(/\x85/g, "\u2026"); result = result.replace(/\x96/g, "\u2013"); @@ -210,3 +232,4 @@ function main(args) { app.quit(); } main(sys.args); +//# sourceMappingURL=file:///c:/ts/scripts/word2md.js.map \ No newline at end of file diff --git a/scripts/word2md.ts b/scripts/word2md.ts index 65b39d6e4f6..ec9ed634b3c 100644 --- a/scripts/word2md.ts +++ b/scripts/word2md.ts @@ -100,9 +100,19 @@ module Word { toggleShowCodes(): void; } + export interface Hyperlink { + address: string; + textToDisplay: string; + range: Range; + } + + export interface Hyperlinks extends Collection { + } + export interface Document { fields: Fields; paragraphs: Paragraphs; + hyperlinks: Hyperlinks; builtInDocumentProperties: Collection; close(saveChanges: boolean): void; range(): Range; @@ -195,6 +205,18 @@ function convertDocumentToMarkdown(doc: Word.Document): string { find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2); } + function fixHyperlinks() { + var count = doc.hyperlinks.count; + for (var i = 0; i < count; i++) { + var hyperlink = doc.hyperlinks.item(i + 1); + var address = hyperlink.address; + if (address && address.length > 0) { + var textToDisplay = hyperlink.textToDisplay; + hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")"; + } + } + } + function write(s: string) { result += s; } @@ -347,6 +369,8 @@ function convertDocumentToMarkdown(doc: Word.Document): string { findReplace("^19 REF", {}, "[^&](#^&)", {}); doc.fields.toggleShowCodes(); + fixHyperlinks(); + writeDocument(); result = result.replace(/\x85/g, "\u2026"); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e7d7a210bbc..1ee3332b824 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -74,7 +74,7 @@ namespace ts { // If the current node is a container that also container that also contains locals. Examples: // // Functions, Methods, Modules, Source-files. - IsContainerWithLocals = IsContainer | HasLocals + IsContainerWithLocals = IsContainer | HasLocals } export function bindSourceFile(file: SourceFile) { @@ -145,7 +145,7 @@ namespace ts { function getDeclarationName(node: Declaration): string { if (node.name) { if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) { - return '"' + (node.name).text + '"'; + return `"${(node.name).text}"`; } if (node.name.kind === SyntaxKind.ComputedPropertyName) { let nameExpression = (node.name).expression; @@ -865,7 +865,7 @@ namespace ts { // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node: Node) { @@ -966,7 +966,7 @@ namespace ts { function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (isExternalModule(file)) { - bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`); } } @@ -1009,6 +1009,10 @@ namespace ts { else { let bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } let symbol = node.symbol; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3f0394fc82b..b2614a49b83 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -91,7 +91,8 @@ namespace ts { getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType, - getJsxIntrinsicTagNames + getJsxIntrinsicTagNames, + isOptionalParameter }; let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); @@ -113,6 +114,10 @@ namespace ts { emptyGenericType.instantiations = {}; let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; + let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -206,6 +211,9 @@ namespace ts { let assignableRelation: Map = {}; let identityRelation: Map = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + let _displayBuilder: SymbolDisplayBuilder; + type TypeSystemEntity = Symbol | Type | Signature; const enum TypeSystemPropertyName { @@ -380,7 +388,7 @@ namespace ts { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } @@ -587,7 +595,19 @@ namespace ts { declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); return undefined; } - if (result.flags & SymbolFlags.BlockScopedVariable) { + + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & SymbolFlags.BlockScopedVariable && result.flags & SymbolFlags.BlockScopedVariable) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -945,28 +965,19 @@ namespace ts { // Escape the name in the "require(...)" clause to ensure we find the right symbol. let moduleName = escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) return; + if (!moduleName) { + return; + } let isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - let symbol = getSymbol(globals, '"' + moduleName + '"', SymbolFlags.ValueModule); + let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); if (symbol) { return symbol; } } - let fileName: string; - let sourceFile: SourceFile; - while (true) { - fileName = normalizePath(combinePaths(searchPath, moduleName)); - sourceFile = forEach(supportedExtensions, extension => host.getSourceFile(fileName + extension)); - if (sourceFile || isRelative) { - break; - } - let parentPath = getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + + let fileName = getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); + let sourceFile = fileName && host.getSourceFile(fileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -1478,8 +1489,6 @@ namespace ts { return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - let _displayBuilder: SymbolDisplayBuilder; function getSymbolDisplayBuilder(): SymbolDisplayBuilder { function getNameOfSymbol(symbol: Symbol): string { @@ -1889,7 +1898,7 @@ namespace ts { function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { let targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) { + if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -1999,15 +2008,15 @@ namespace ts { } return _displayBuilder || (_displayBuilder = { - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay + buildSymbolDisplay, + buildTypeDisplay, + buildTypeParameterDisplay, + buildParameterDisplay, + buildDisplayForParametersAndDelimiters, + buildDisplayForTypeParametersAndDelimiters, + buildTypeParameterDisplayFromSymbol, + buildSignatureDisplay, + buildReturnTypeDisplay }); } @@ -2164,10 +2173,13 @@ namespace ts { node = getOriginalNodeIf(node, isIdentifier); let exportSymbol: Symbol; if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { - exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + let exportSpecifier = node.parent; + exportSymbol = (exportSpecifier.parent.parent).moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } let result: Node[] = []; if (exportSymbol) { @@ -3114,58 +3126,72 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function findMatchingSignature(signature: Signature, signatureList: Signature[]): Signature { - for (let s of signatureList) { - // Only signatures with no type parameters may differ in return types - if (compareSignatures(signature, s, /*compareReturnTypes*/ !!signature.typeParameters, compareTypes)) { + function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature { + for (let s of signatureList) { + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } } } - function findMatchingSignatures(signature: Signature, signatureLists: Signature[][]): Signature[] { + function findMatchingSignatures(signatureLists: Signature[][], signature: Signature, listIndex: number): Signature[] { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; + } + for (let i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } + } + return [signature]; + } let result: Signature[] = undefined; - for (let i = 1; i < signatureLists.length; i++) { - let match = findMatchingSignature(signature, signatureLists[i]); + for (let i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + let match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } - if (!result) { - result = [signature]; - } - if (match !== signature) { - result.push(match); + if (!contains(result, match)) { + (result || (result = [])).push(match); } } return result; } - // The signatures of a union type are those signatures that are present and identical in each of the - // constituent types, except that non-generic signatures may differ in return types. When signatures - // differ in return types, the resulting return type is the union of the constituent return types. + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] { let signatureLists = map(types, t => getSignaturesOfType(t, kind)); let result: Signature[] = undefined; - for (let source of signatureLists[0]) { - let unionSignatures = findMatchingSignatures(source, signatureLists); - if (unionSignatures) { - let signature: Signature = undefined; - if (unionSignatures.length === 1 || source.typeParameters) { - signature = source; + for (let i = 0; i < signatureLists.length; i++) { + for (let signature of signatureLists[i]) { + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + let unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + let s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } } - else { - signature = cloneSignature(source); - // Clear resolved return type we possibly got from cloneSignature - signature.resolvedReturnType = undefined; - signature.unionSignatures = unionSignatures; - } - (result || (result = [])).push(signature); } } return result || emptyArray; @@ -3432,29 +3458,6 @@ namespace ts { return undefined; } - // Check if a property with the given name is known anywhere in the given type. In an object - // type, a property is considered known if the object type is empty, if it has any index - // signatures, or if the property is actually declared in the type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { - var resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & TypeFlags.UnionOrIntersection) { - for (let t of (type).types) { - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } - function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { let resolved = resolveStructuredTypeMembers(type); @@ -3463,8 +3466,10 @@ namespace ts { return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -3524,7 +3529,19 @@ namespace ts { } function isOptionalParameter(node: ParameterDeclaration) { - return hasQuestionToken(node) || !!node.initializer; + if (hasQuestionToken(node)) { + return true; + } + + if (node.initializer) { + let signatureDeclaration = node.parent; + let signature = getSignatureFromDeclaration(signatureDeclaration); + let parameterIndex = signatureDeclaration.parameters.indexOf(node); + Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + + return false; } function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { @@ -3542,11 +3559,16 @@ namespace ts { if (param.type && param.type.kind === SyntaxKind.StringLiteral) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { @@ -3764,22 +3786,23 @@ namespace ts { } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types: Type[]): TypeFlags { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types: Type[]): TypeFlags { let result: TypeFlags = 0; for (let type of types) { result |= type.flags; } - return result & TypeFlags.RequiresWidening; + return result & TypeFlags.PropagatingFlags; } function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference { let id = getTypeListId(typeArguments); let type = target.instantiations[id]; if (!type) { - let flags = TypeFlags.Reference | getWideningFlagsOfTypes(typeArguments); + let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -4033,7 +4056,7 @@ namespace ts { let id = getTypeListId(elementTypes); let type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(TypeFlags.Tuple | getWideningFlagsOfTypes(elementTypes)); + type = tupleTypes[id] = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -4064,73 +4087,20 @@ namespace ts { } } - function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean { - let sourceProperties = getPropertiesOfObjectType(source); - let targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (let sourceProp of sourceProperties) { - let targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - - function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean { - let sourceTypes = source.elementTypes; - let targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - - // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of - // a target type if the the two are identical, with the exception that the source type may have null or - // undefined in places where the target type doesn't. This is by design an asymmetric relationship. - function isTypeDuplicateOf(source: Type, target: Type): boolean { - if (source === target) { - return true; - } - if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) { - return true; - } - if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf((source).typeArguments[0], (target).typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - - function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean { - for (let type of types) { - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + for (let i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types: Type[]) { + function removeSubtypes(types: Type[]) { let i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -4155,12 +4125,14 @@ namespace ts { } } - // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate - // based on the structure of the types unless the noDeduplication flag is true, which is the case when - // creating a union type from a type node and when instantiating a union type. In both of those cases, - // structural deduplication has to be deferred to properly support recursive union types. For example, - // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. - function getUnionType(types: Type[], noDeduplication?: boolean): Type { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { if (types.length === 0) { return emptyObjectType; } @@ -4169,12 +4141,12 @@ namespace ts { if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -4182,7 +4154,7 @@ namespace ts { let id = getTypeListId(typeSet); let type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -4191,7 +4163,7 @@ namespace ts { function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { let links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -4216,7 +4188,7 @@ namespace ts { let id = getTypeListId(typeSet); let type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -4448,6 +4420,15 @@ namespace ts { } function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType { + if (mapper.instantiations) { + let cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it let result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -4458,6 +4439,7 @@ namespace ts { let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } @@ -4477,7 +4459,7 @@ namespace ts { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } if (type.flags & TypeFlags.Union) { - return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & TypeFlags.Intersection) { return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); @@ -4640,19 +4622,21 @@ namespace ts { let result: Ternary; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; - if (relation !== identityRelation) { - if (isTypeAny(target)) return Ternary.True; - if (source === undefinedType) return Ternary.True; - if (source === nullType && target !== undefinedType) return Ternary.True; - if (source.flags & TypeFlags.Enum && target === numberType) return Ternary.True; - if (source.flags & TypeFlags.StringLiteral && target === stringType) return Ternary.True; - if (relation === assignableRelation) { - if (isTypeAny(source)) return Ternary.True; - if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True; - } + if (relation === identityRelation) { + return isIdenticalTo(source, target); } - if (relation !== identityRelation && source.flags & TypeFlags.FreshObjectLiteral) { + if (isTypeAny(target)) return Ternary.True; + if (source === undefinedType) return Ternary.True; + if (source === nullType && target !== undefinedType) return Ternary.True; + if (source.flags & TypeFlags.Enum && target === numberType) return Ternary.True; + if (source.flags & TypeFlags.StringLiteral && target === stringType) return Ternary.True; + if (relation === assignableRelation) { + if (isTypeAny(source)) return Ternary.True; + if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True; + } + + if (source.flags & TypeFlags.FreshObjectLiteral) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -4668,78 +4652,66 @@ namespace ts { let saveErrorInfo = errorInfo; - if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & TypeFlags.Union) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & TypeFlags.Intersection) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & TypeFlags.Union) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & TypeFlags.Intersection) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & TypeFlags.Intersection) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { - return result; - } - } - if (target.flags & TypeFlags.Union) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || - source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & TypeFlags.Intersection) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { + return result; + } + } + if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & TypeFlags.TypeParameter) { + let constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & TypeFlags.Any) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + let reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.UnionOrIntersection) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + let apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { + // Report structural errors only if we haven't reported any errors yet + let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } @@ -4749,6 +4721,55 @@ namespace ts { return Ternary.False; } + function isIdenticalTo(source: Type, target: Type): Ternary { + let result: Ternary; + if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || + source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return Ternary.False; + } + + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type: Type, name: string): boolean { + if (type.flags & TypeFlags.ObjectType) { + const resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & TypeFlags.UnionOrIntersection) { + for (let t of (type).types) { + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { @@ -4833,29 +4854,18 @@ namespace ts { return result; } - function typeParameterRelatedTo(source: TypeParameter, target: TypeParameter, reportErrors: boolean): Ternary { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return Ternary.False; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return Ternary.True; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return Ternary.False; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - let constraint = getConstraintOfTypeParameter(source); - if (constraint === target) return Ternary.True; - if (!(constraint && constraint.flags & TypeFlags.TypeParameter)) break; - source = constraint; - } + function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary { + if (source.symbol.name !== target.symbol.name) { return Ternary.False; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return Ternary.True; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return Ternary.False; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. @@ -5057,30 +5067,24 @@ namespace ts { let result = Ternary.True; let saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - let sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - let targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - let sourceErasedSignature = getErasedSignature(sourceSig); - let targetErasedSignature = getErasedSignature(targetSig); - let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + if (kind === SignatureKind.Construct) { + // Only want to compare the construct signatures for abstractness guarantees. + + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + let sourceSig = sourceSignatures[0]; + let targetSig = targetSignatures[0]; - let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); - let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); - let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; - let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; - - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return Ternary.False; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== Ternary.True) { + return result; } } @@ -5104,6 +5108,40 @@ namespace ts { } } return result; + + function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) { + if (sourceSig && targetSig) { + + let sourceDecl = source.symbol && getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration); + let targetDecl = target.symbol && getDeclarationOfKind(target.symbol, SyntaxKind.ClassDeclaration); + + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return Ternary.True; + } + + let sourceErasedSignature = getErasedSignature(sourceSig); + let targetErasedSignature = getErasedSignature(targetSig); + + let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + + let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); + let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; + let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; + + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return Ternary.False; + } + } + return Ternary.True; + } } function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary { @@ -5209,7 +5247,7 @@ namespace ts { } let result = Ternary.True; for (let i = 0, len = sourceSignatures.length; i < len; ++i) { - let related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*compareReturnTypes*/ true, isRelatedTo); + let related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return Ternary.False; } @@ -5223,7 +5261,7 @@ namespace ts { return indexTypesIdenticalTo(IndexKind.String, source, target); } let targetType = getIndexTypeOfType(target, IndexKind.String); - if (targetType) { + if (targetType && !(targetType.flags & TypeFlags.Any)) { let sourceType = getIndexTypeOfType(source, IndexKind.String); if (!sourceType) { if (reportErrors) { @@ -5248,7 +5286,7 @@ namespace ts { return indexTypesIdenticalTo(IndexKind.Number, source, target); } let targetType = getIndexTypeOfType(target, IndexKind.Number); - if (targetType) { + if (targetType && !(targetType.flags & TypeFlags.Any)) { let sourceStringType = getIndexTypeOfType(source, IndexKind.String); let sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); if (!(sourceStringType || sourceNumberType)) { @@ -5339,14 +5377,18 @@ namespace ts { return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source: Signature, target: Signature, compareReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary { + function compareSignatures(source: Signature, target: Signature, partialMatch: boolean, ignoreReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary { if (source === target) { return Ternary.True; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return Ternary.False; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return Ternary.False; + } } let result = Ternary.True; if (source.typeParameters && target.typeParameters) { @@ -5368,16 +5410,18 @@ namespace ts { // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (let i = 0, len = source.parameters.length; i < len; i++) { - let s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - let t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + let sourceLen = source.parameters.length; + let targetLen = target.parameters.length; + for (let i = 0; i < targetLen; i++) { + let s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + let t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); let related = compareTypes(s, t); if (!related) { return Ternary.False; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -5507,7 +5551,7 @@ namespace ts { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, getWidenedType)); + return getUnionType(map((type).types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType((type).typeArguments[0])); @@ -5663,11 +5707,17 @@ namespace ts { } function inferFromTypes(source: Type, target: Type) { - if (source === anyFunctionType) { - return; - } if (target.flags & TypeFlags.TypeParameter) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & TypeFlags.ContainsAnyFunctionType) { + return; + } + let typeParameters = context.typeParameters; for (let i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -5698,6 +5748,14 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & TypeFlags.Tuple && target.flags & TypeFlags.Tuple && (source).elementTypes.length === (target).elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + let sourceTypes = (source).elementTypes; + let targetTypes = (target).elementTypes; + for (let i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & TypeFlags.UnionOrIntersection) { let targetTypes = (target).types; let typeParameterCount = 0; @@ -6173,14 +6231,20 @@ namespace ts { } function getNarrowedType(originalType: Type, narrowedTypeCandidate: Type) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check + if (originalType.flags & TypeFlags.Union) { + let assignableConstituents = filter((originalType).types, t => isTypeAssignableTo(t, narrowedTypeCandidate)); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type return narrowedTypeCandidate; } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. - if (originalType.flags & TypeFlags.Union) { - return getUnionType(filter((originalType).types, t => isTypeSubtypeOf(t, narrowedTypeCandidate))); - } + return originalType; } @@ -6402,22 +6466,79 @@ namespace ts { let classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); let baseClassType = classType && getBaseTypes(classType)[0]; + let container = getSuperContainer(node, /*includeFunctions*/ true); + let needToCaptureLexicalThis = false; + + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === SyntaxKind.ArrowFunction) { + container = getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; + } + } + + let canUseSuperExpression = isLegalUsageOfSuperExpression(container); + let nodeCheckFlag: NodeCheckFlags = 0; + + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & NodeFlags.Static) || isCallExpression) { + nodeCheckFlag = NodeCheckFlags.SuperStatic; + } + else { + nodeCheckFlag = NodeCheckFlags.SuperInstance; + } + + getNodeLinks(node).flags |= nodeCheckFlag; + + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } + if (!baseClassType) { if (!classDeclaration || !getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); } + return unknownType; + } + + if (!canUseSuperExpression) { + if (container && container.kind === SyntaxKind.ComputedPropertyName) { + error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; } + + if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + + return nodeCheckFlag === NodeCheckFlags.SuperStatic + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + + function isLegalUsageOfSuperExpression(container: Node): boolean { + if (!container) { + return false; + } - let container = getSuperContainer(node, /*includeFunctions*/ true); - - if (container) { - let canUseSuperExpression = false; - let needToCaptureLexicalThis: boolean; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === SyntaxKind.Constructor; + return container.kind === SyntaxKind.Constructor; } else { // TS 1.0 SPEC (April 2014) @@ -6425,75 +6546,28 @@ namespace ts { // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === SyntaxKind.ArrowFunction) { - container = getSuperContainer(container, /*includeFunctions*/ true); - needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; - } - // topmost container must be something that is directly nested in the class declaration if (container && isClassLike(container.parent)) { if (container.flags & NodeFlags.Static) { - canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + return container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { - canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + return container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } - - if (canUseSuperExpression) { - let returnType: Type; - - if ((container.flags & NodeFlags.Static) || isCallExpression) { - getNodeLinks(node).flags |= NodeCheckFlags.SuperStatic; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= NodeCheckFlags.SuperInstance; - returnType = baseClassType; - } - - if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - - return returnType; - } - } - - if (container && container.kind === SyntaxKind.ComputedPropertyName) { - error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - - return unknownType; + + return false; + } } // Return contextual type of parameter or undefined if no contextual type is available @@ -6861,20 +6935,13 @@ namespace ts { let signatureList: Signature[]; let types = (type).types; for (let current of types) { - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, SignatureKind.Call).length > 1) { - return undefined; - } - let signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, /*compareReturnTypes*/ false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -7051,7 +7118,7 @@ namespace ts { let propertiesTable: SymbolTable = {}; let propertiesArray: Symbol[] = []; let contextualType = getContextualType(node); - let typeFlags: TypeFlags; + let typeFlags: TypeFlags = 0; for (let memberDecl of node.properties) { let member = memberDecl.symbol; @@ -7100,7 +7167,8 @@ namespace ts { let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull); + let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; + result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); return result; function getIndexType(kind: IndexKind) { @@ -7146,13 +7214,17 @@ namespace ts { } function checkJsxElement(node: JsxElement) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName)); } - - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (let child of node.children) { @@ -7206,10 +7278,19 @@ namespace ts { else if (elementAttributesType && !isTypeAny(elementAttributesType)) { let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + let indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); + if (indexerType) { + correspondingPropType = indexerType + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } @@ -7263,7 +7344,7 @@ namespace ts { /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class /// type or factory function. /// Otherwise, returns unknownSymbol. - function getJsxElementTagSymbol(node: JsxOpeningLikeElement): Symbol { + function getJsxElementTagSymbol(node: JsxOpeningLikeElement|JsxClosingElement): Symbol { let flags: JsxFlags = JsxFlags.UnknownElement; let links = getNodeLinks(node); if (!links.resolvedSymbol) { @@ -7275,7 +7356,7 @@ namespace ts { } return links.resolvedSymbol; - function lookupIntrinsicTag(node: JsxOpeningLikeElement): Symbol { + function lookupIntrinsicTag(node: JsxOpeningLikeElement|JsxClosingElement): Symbol { let intrinsicElementsType = getJsxIntrinsicElementsType(); if (intrinsicElementsType !== unknownType) { // Property case @@ -7293,7 +7374,7 @@ namespace ts { } // Wasn't found - error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (node.tagName).text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (node.tagName).text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -7303,19 +7384,10 @@ namespace ts { } } - function lookupClassTag(node: JsxOpeningLikeElement): Symbol { - let valueSymbol: Symbol; + function lookupClassTag(node: JsxOpeningLikeElement|JsxClosingElement): Symbol { + let valueSymbol: Symbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === SyntaxKind.Identifier) { - let tag = node.tagName; - let sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } - if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; getSymbolLinks(valueSymbol).referenced = true; @@ -7323,6 +7395,17 @@ namespace ts { return valueSymbol || unknownSymbol; } + + function resolveJsxTagName(node: JsxOpeningLikeElement|JsxClosingElement): Symbol { + if (node.tagName.kind === SyntaxKind.Identifier) { + let tag = node.tagName; + let sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** @@ -7331,10 +7414,9 @@ namespace ts { * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node: JsxOpeningLikeElement) { - if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), "Should not call getJsxElementInstanceType on non-class Element"); let classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { @@ -7357,16 +7439,11 @@ namespace ts { if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); - if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { - error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + let returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass let elemClassType = getJsxGlobalElementClassType(); @@ -7427,7 +7504,7 @@ namespace ts { let elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } let propsName = getJsxElementPropertiesName(); @@ -7519,7 +7596,7 @@ namespace ts { // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === JsxEmit.React) { - let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); + let reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -10413,17 +10490,21 @@ namespace ts { return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; } + function containsSuperCallAsComputedPropertyName(n: Declaration): boolean { + return n.name && containsSuperCall(n.name); + } + function containsSuperCall(n: Node): boolean { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: - case SyntaxKind.ObjectLiteralExpression: return false; - default: return forEachChild(n, containsSuperCall); + else if (isFunctionLike(n)) { + return false; } + else if (isClassLike(n)) { + return forEach((n).members, containsSuperCallAsComputedPropertyName); + } + return forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n: Node): void { @@ -10444,9 +10525,17 @@ namespace ts { // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (getClassExtendsHeritageClauseElement(node.parent)) { + let containingClassDecl = node.parent; + if (getClassExtendsHeritageClauseElement(containingClassDecl)) { + let containingClassSymbol = getSymbolOfNode(containingClassDecl); + let containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + let baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call // if both of the following are true: // - The containing class is a derived class. @@ -10479,7 +10568,7 @@ namespace ts { } } } - else { + else if (baseConstructorType !== nullType) { error(node, Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -10870,9 +10959,6 @@ namespace ts { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. - // if localSymbol is defined on node then node itself is exported - check is required let symbol = node.localSymbol; if (!symbol) { @@ -10892,27 +10978,45 @@ namespace ts { // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - let exportedDeclarationSpaces: SymbolFlags = 0; - let nonExportedDeclarationSpaces: SymbolFlags = 0; - forEach(symbol.declarations, d => { + let exportedDeclarationSpaces = SymbolFlags.None; + let nonExportedDeclarationSpaces = SymbolFlags.None; + let defaultExportedDeclarationSpaces = SymbolFlags.None; + for (let d of symbol.declarations) { let declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, NodeFlags.Export)) { - exportedDeclarationSpaces |= declarationSpaces; + let effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default); + + if (effectiveDeclarationFlags & NodeFlags.Export) { + if (effectiveDeclarationFlags & NodeFlags.Default) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); + } - let commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + // Spaces for anyting not declared a 'default export'. + let nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + + let commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + let commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpace) { + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - forEach(symbol.declarations, d => { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (let d of symbol.declarations) { + let declarationSpaces = getDeclarationSpaces(d); + + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d: Declaration): SymbolFlags { @@ -11248,9 +11352,16 @@ namespace ts { // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let root = getFirstIdentifier((node).typeName); - let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; + // Resolve type so we know which symbol is referenced + let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) { + let aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -12460,6 +12571,7 @@ namespace ts { if (baseTypes.length && produceDiagnostics) { let baseType = baseTypes[0]; let staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { @@ -12757,28 +12869,7 @@ namespace ts { } let initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -12792,8 +12883,36 @@ namespace ts { nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed; } - function getConstantValueForEnumMemberInitializer(initializer: Expression): number { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer: Expression, enumType: Type, enumIsConst: boolean, ambient: boolean): number { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + let reportError = true; + let value = evalConstant(initializer); + + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + + return value; function evalConstant(e: Node): number { switch (e.kind) { @@ -12902,6 +13021,8 @@ namespace ts { // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } @@ -13177,7 +13298,7 @@ namespace ts { } } else { - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } @@ -13520,6 +13641,8 @@ namespace ts { case SyntaxKind.VariableDeclaration: case SyntaxKind.VariableDeclarationList: case SyntaxKind.ClassDeclaration: + case SyntaxKind.HeritageClause: + case SyntaxKind.ExpressionWithTypeArguments: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: @@ -13700,7 +13823,11 @@ namespace ts { } break; } - + + if (introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; location = location.parent; } @@ -13819,7 +13946,9 @@ namespace ts { meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) || (entityName.parent.kind === SyntaxKind.JsxSelfClosingElement)) { + else if ((entityName.parent.kind === SyntaxKind.JsxOpeningElement) || + (entityName.parent.kind === SyntaxKind.JsxSelfClosingElement) || + (entityName.parent.kind === SyntaxKind.JsxClosingElement)) { return getJsxElementTagSymbol(entityName.parent); } else if (isPartOfExpression(entityName)) { @@ -14254,15 +14383,21 @@ namespace ts { return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0; } - function getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind { + function getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - let symbol = resolveEntityName(node.typeName, SymbolFlags.Value, /*ignoreErrors*/ true); - let constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + let valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true); + let constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - let type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return TypeReferenceSerializationKind.ObjectType; + } + let type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return TypeReferenceSerializationKind.Unknown; } @@ -14398,6 +14533,7 @@ namespace ts { getBlockScopedVariableId, getReferencedValueDeclaration, getTypeReferenceSerializationKind, + isOptionalParameter }; } @@ -14793,17 +14929,15 @@ namespace ts { return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 920f05c6026..1de25fd57f3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -30,6 +30,11 @@ namespace ts { type: "boolean", description: Diagnostics.Print_this_message, }, + { + name: "init", + type: "boolean", + description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, { name: "inlineSourceMap", type: "boolean", @@ -120,6 +125,13 @@ namespace ts { { name: "out", type: "string", + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + paramType: Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", isFilePath: true, description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, @@ -172,6 +184,12 @@ namespace ts { description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -223,22 +241,50 @@ namespace ts { type: "boolean", experimental: true, description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - } + }, + { + name: "moduleResolution", + type: { + "node": ModuleResolutionKind.NodeJs, + "classic": ModuleResolutionKind.Classic + }, + experimental: true, + description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6 + } ]; - export function parseCommandLine(commandLine: string[]): ParsedCommandLine { - let options: CompilerOptions = {}; - let fileNames: string[] = []; - let errors: Diagnostic[] = []; - let shortOptionNames: Map = {}; - let optionNameMap: Map = {}; + /* @internal */ + export interface OptionNameMap { + optionNameMap: Map; + shortOptionNames: Map; + } + let optionNameMapCache: OptionNameMap; + /* @internal */ + export function getOptionNameMap(): OptionNameMap { + if (optionNameMapCache) { + return optionNameMapCache; + } + + let optionNameMap: Map = {}; + let shortOptionNames: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + + optionNameMapCache = { optionNameMap, shortOptionNames }; + return optionNameMapCache; + } + + export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine { + let options: CompilerOptions = {}; + let fileNames: string[] = []; + let errors: Diagnostic[] = []; + let { optionNameMap, shortOptionNames } = getOptionNameMap(); + parseStrings(commandLine); return { options, @@ -302,7 +348,7 @@ namespace ts { } function parseResponseFile(fileName: string) { - let text = sys.readFile(fileName); + let text = readFile ? readFile(fileName) : sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); @@ -340,7 +386,7 @@ namespace ts { * @param fileName The path to the config file */ export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } { - let text = ''; + let text = ""; try { text = sys.readFile(fileName); } @@ -427,6 +473,9 @@ namespace ts { if (json["files"] instanceof Array) { fileNames = map(json["files"], s => combinePaths(basePath, s)); } + else { + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; @@ -452,4 +501,4 @@ namespace ts { return fileNames; } } -} +} diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fa05840e33b..73d050bf2c0 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -24,6 +24,7 @@ namespace ts { set, contains, remove, + clear, forEachValue: forEachValueInMap }; @@ -51,6 +52,10 @@ namespace ts { function normalizeKey(key: string) { return getCanonicalFileName(normalizeSlashes(key)); } + + function clear() { + files = {}; + } } export const enum Comparison { @@ -228,6 +233,13 @@ namespace ts { return array[array.length - 1]; } + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ export function binarySearch(array: number[], value: number): number { let low = 0; let high = array.length - 1; @@ -254,10 +266,10 @@ namespace ts { export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial?: U): U { if (array) { - var count = array.length; + const count = array.length; if (count > 0) { - var pos = 0; - var result = arguments.length <= 2 ? array[pos++] : initial; + let pos = 0; + let result = arguments.length <= 2 ? array[pos++] : initial; while (pos < count) { result = f(result, array[pos++]); } @@ -271,9 +283,9 @@ namespace ts { export function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; export function reduceRight(array: T[], f: (a: U, x: T) => U, initial?: U): U { if (array) { - var pos = array.length - 1; + let pos = array.length - 1; if (pos >= 0) { - var result = arguments.length <= 2 ? array[pos--] : initial; + let result = arguments.length <= 2 ? array[pos--] : initial; while (pos >= 0) { result = f(result, array[pos--]); } @@ -310,14 +322,14 @@ namespace ts { return result; } - export function extend(first: Map, second: Map): Map { - let result: Map = {}; + export function extend(first: Map, second: Map): Map { + let result: Map = {}; for (let id in first) { - result[id] = first[id]; + (result as any)[id] = first[id]; } for (let id in second) { if (!hasProperty(result, id)) { - result[id] = second[id]; + (result as any)[id] = second[id]; } } return result; @@ -558,7 +570,7 @@ namespace ts { if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - let idx = path.indexOf('://'); + let idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -744,7 +756,7 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedExtensions = [".tsx", ".ts", ".d.ts"]; + export const supportedExtensions = [".ts", ".tsx", ".d.ts"]; const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { @@ -806,7 +818,10 @@ namespace ts { original: undefined, transformFlags: undefined, excludeTransformFlags: undefined, - modifiers: undefined + modifiers: undefined, + createParentNavigator(): ParentNavigator { + return createParentNavigator(this); + } }; return Node; }, @@ -815,6 +830,249 @@ namespace ts { getSignatureConstructor: () => Signature }; + /** + * Creates an object used to navigate the ancestor's of a node by following parent pointers. + * @param currentNode The current node for the navigator. + */ + export function createParentNavigator(currentNode: Node): ParentNavigator { + /** Traverses the parent pointers for the current node to find the root node. */ + function getRoot() { + let rootNode = currentNode; + while (rootNode && rootNode.parent) { + rootNode = rootNode.parent; + } + + return rootNode; + } + + /** Gets the grandparent of the current node, without moving the navigator. */ + function getGrandparent() { + let parent = getParent(); + return parent ? parent.parent : undefined; + } + + /** Gets the parent of the current node, without moving the navigator. */ + function getParent() { + return currentNode ? currentNode.parent : undefined; + } + + /** Gets the current node. */ + function getNode() { + return currentNode; + } + + /** Gets the SyntaxKind for the current node. */ + function getKind() { + return currentNode ? currentNode.kind : undefined; + } + + /** Navigates to the parent of the current node if it has one. */ + function moveToParent(): boolean { + let parent = getParent(); + if (parent) { + currentNode = parent; + return true; + } + + return false; + } + + /** Navigates to the root node for the current node. */ + function moveToRoot(): boolean { + let rootNode = getRoot(); + if (rootNode) { + currentNode = rootNode; + return true; + } + + return false; + } + + /** Creates a new ParentNavigator from the current node. */ + function createParentNavigator() { + return ts.createParentNavigator(currentNode); + } + + return { + getRoot, + getGrandparent, + getParent, + getNode, + getKind, + moveToParent, + moveToRoot, + createParentNavigator, + }; + } + + /** + * Creates a node stack used to maintain parent relationships without parent pointers. + */ + export function createNodeStack(): NodeStack { + let stackSize: number = 0; + let stack: Node[] = []; + let rootNode: Node; + let parentNode: Node; + let currentNode: Node; + + /** Gets the node at the bottom of the stack. */ + function getRoot() { + return rootNode; + } + + /** Gets the node two steps back from the top of the stack. */ + function getGrandparent() { + return peekNode(2); + } + + /** Gets the node one step back from the top of the stack. */ + function getParent() { + return parentNode; + } + + /** Gets the node at the top of the stack. */ + function getNode() { + return currentNode; + } + + /** Gets the SyntaxKind for the node at the top of the stack. */ + function getKind() { + return currentNode ? currentNode.kind : undefined; + } + + /** Pushes a node onto the stack. */ + function pushNode(node: Node): void { + stackSize++; + if (stackSize > 2) { + stack.push(parentNode); + } + else if (stackSize === 1) { + rootNode = node; + } + parentNode = currentNode; + currentNode = node; + } + + /** Pops the top node from the stack. */ + function popNode(): void { + currentNode = parentNode; + parentNode = stackSize > 2 ? stack.pop() : undefined; + stackSize--; + if (stackSize === 0) { + rootNode = undefined; + } + } + + /** Replaces the node at the top of the stack. */ + function setNode(node: Node): void { + currentNode = node; + } + + /** Peeks at a node a specified number of steps back from the top of the stack. */ + function peekNode(stackOffset: number): Node { + switch (stackOffset) { + case 0: return currentNode; + case 1: return parentNode; + default: return stackSize > 2 ? stack[stackSize - 1 - stackOffset] : undefined; + } + } + + /** Traverses the stack from top to bottom until it finds a node that matches the supplied predicate. */ + function findAncestorNode(match: (node: Node) => node is T): T; + /** Traverses the stack from top to bottom until it finds a node that matches the supplied predicate. */ + function findAncestorNode(match: (node: Node) => boolean): Node; + function findAncestorNode(match: (node: Node) => boolean) { + if (parentNode && match(parentNode)) { + return parentNode; + } + for (let i = stack.length; i >= 0; i--) { + let node = stack[i]; + if (match(node)) { + return node; + } + } + return undefined; + } + + /** Creates a parent navigator from the top of the stack. */ + function createParentNavigator() { + return createParentNavigatorFromStackOffset(0); + } + + /** Creates a parent navigator a specified number of steps back from the top of the stack. */ + function createParentNavigatorFromStackOffset(stackOffset: number): ParentNavigator { + /** Gets the node two steps back from the current stack offset. */ + function getGrandparent() { + return peekNode(stackOffset + 2); + } + + /** Gets the node one step back from the current stack offset. */ + function getParent() { + return peekNode(stackOffset + 1); + } + + /** Gets the node at the current stack offset. */ + function getNode() { + return peekNode(stackOffset); + } + + /** Gets the SyntaxKind of the node at the current stack offset. */ + function getKind() { + let node = getNode(); + return node ? node.kind : undefined; + } + + /** Navigates to the node one step back from the current stack offset. */ + function moveToParent() { + if (getParent()) { + stackOffset++; + return true; + } + + return false; + } + + /** Navigates to the node at the bottom of the stack. */ + function moveToRoot() { + if (stackSize > 0) { + stackOffset = stackSize; + return true; + } + + return false; + } + + /** Creates a new ParentNavigator from the current stack offset. */ + function createParentNavigator() { + return createParentNavigatorFromStackOffset(stackOffset); + } + + return { + getRoot, + getGrandparent, + getParent, + getNode, + getKind, + moveToRoot, + moveToParent, + createParentNavigator, + }; + } + + return { + getRoot, + getGrandparent, + getParent, + getNode, + getKind, + pushNode, + popNode, + setNode, + findAncestorNode, + createParentNavigator, + }; + } + export const enum AssertionLevel { None = 0, Normal = 1, diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 31a994fab07..bc9a0129d9d 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -750,14 +750,18 @@ namespace ts { } function writeTypeAliasDeclaration(node: TypeAliasDeclaration) { + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { return { @@ -892,6 +896,9 @@ namespace ts { if (isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; @@ -1371,7 +1378,7 @@ namespace ts { else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); @@ -1497,11 +1504,8 @@ namespace ts { // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -1573,7 +1577,7 @@ namespace ts { ? referencedFile.fileName // Declaration file, use declaration file name : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizeSlashes(jsFilePath)), diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index ecea3a76673..f7351bf6912 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -294,7 +294,7 @@ namespace ts { Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -425,6 +425,8 @@ namespace ts { JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -504,19 +506,12 @@ namespace ts { Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -567,11 +562,14 @@ namespace ts { Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -613,5 +611,6 @@ namespace ts { Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2765d04f400..9fd08ef9bca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1,4 +1,4 @@ -{ + { "Unterminated string literal.": { "category": "Error", "code": 1002 @@ -161,7 +161,7 @@ }, "Type '{0}' is not a valid async function return type.": { "category": "Error", - "code": 1055 + "code": 1055 }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", @@ -1165,7 +1165,7 @@ "category": "Error", "code": 2394 }, - "Individual declarations in merged declaration {0} must be all exported or all local.": { + "Individual declarations in merged declaration '{0}' must be all exported or all local.": { "category": "Error", "code": 2395 }, @@ -1689,6 +1689,14 @@ "category": "Error", "code": 2650 }, + "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { + "category": "Error", + "code": 2651 + }, + "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": { + "category": "Error", + "code": 2652 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2005,58 +2013,30 @@ "category": "Error", "code": 5033 }, - "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5038 - }, - "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5039 - }, - "Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": { - "category": "Error", - "code": 5040 - }, - "Option 'noEmit' cannot be specified with option 'declaration'.": { - "category": "Error", - "code": 5041 - }, "Option 'project' cannot be mixed with source files on a command line.": { "category": "Error", "code": 5042 }, - "Option 'declaration' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5044 - }, - "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5045 - }, - "Option 'out' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5046 - }, "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { "category": "Error", "code": 5047 }, - "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5048 - }, - "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5049 - }, - "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5050 - }, "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, + "Option '{0}' cannot be specified without specifying option '{1}'.": { + "category": "Error", + "code": 5052 + }, + "Option '{0}' cannot be specified with option '{1}'.": { + "category": "Error", + "code": 5053 + }, + "A 'tsconfig.json' file is already defined at: '{0}'.": { + "category": "Error", + "code": 5053 + }, "Concatenate and emit output to single file.": { "category": "Message", @@ -2258,10 +2238,6 @@ "category": "Message", "code": 6081 }, - "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { - "category": "Error", - "code": 6064 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2278,6 +2254,22 @@ "category": "Message", "code": 6068 }, + "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": { + "category": "Message", + "code": 6069 + }, + "Initializes a TypeScript project and creates a tsconfig.json file.": { + "category": "Message", + "code": 6070 + }, + "Successfully created a tsconfig.json file.": { + "category": "Message", + "code": 6071 + }, + "Suppress excess property checks for object literals.": { + "category": "Message", + "code": 6072 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", @@ -2445,5 +2437,9 @@ "Cannot use JSX unless the '--jsx' flag is provided.": { "category": "Error", "code": 17004 + }, + "A constructor cannot contain a 'super' call when its class extends 'null'": { + "category": "Error", + "code": 17005 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 90836e2db5a..29d7e6b43eb 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -86,18 +86,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } @@ -136,11 +136,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitJavaScript(jsFilePath: string, root?: SourceFile) { let writer = createTextWriter(newLine); - let write = writer.write; - let writeTextOfNode = writer.writeTextOfNode; - let writeLine = writer.writeLine; - let increaseIndent = writer.increaseIndent; - let decreaseIndent = writer.decreaseIndent; + let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer; let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module @@ -159,10 +155,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // tree as we descend into the branch. It is used to derive the parent // node of any node without needing parent pointers, to help with // the emit of synthesized nodes that do not maintain parent pointers. - let nodeStackSize: number = 0; - let ancestorStack: Node[] = []; - let parentNode: Node; - let currentNode: Node; + let nodeStack: NodeStack; + let pushNode: (node: Node) => void; + let popNode: () => void; let extendsEmitted = false; let decorateEmitted = false; @@ -184,7 +179,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let writeComment = writeCommentRange; /** Emit a node */ - let emit = emitNodeWithoutSourceMap; + let emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ let emitStart = function (node: Node) { }; @@ -234,52 +229,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitSourceFile(sourceFile: SourceFile): void { currentSourceFile = sourceFile; exportFunctionForFile = undefined; - nodeStackSize = 0; - ancestorStack.length = 0; - parentNode = undefined; - currentNode = undefined; + nodeStack = createNodeStack(); + pushNode = nodeStack.pushNode; + popNode = nodeStack.popNode; emit(sourceFile); } - function pushNode(node: Node): void { - Debug.assert(node !== undefined, "Incorrect node stack behavior during push. Argument `node` is undefined.") - Debug.assert(currentNode !== node, "Incorrect node stack behavior during push. Argument `node` is already the current node."); - Debug.assert(parentNode !== node, "Incorrect node stack behavior during push. Argument `node` is already the parent node."); - nodeStackSize++; - if (nodeStackSize > 2) { - ancestorStack.push(parentNode); - } - parentNode = currentNode; - currentNode = node; - } - - function popNode(): void { - currentNode = parentNode; - parentNode = nodeStackSize > 2 ? ancestorStack.pop() : undefined; - nodeStackSize--; - } - - function peekNode(offset: number): Node { - switch (offset) { - case 0: return currentNode; - case 1: return parentNode; - default: return nodeStackSize > 2 ? ancestorStack[nodeStackSize - 1 - offset] : undefined; - } - } - function findAncestorNode(match: (node: Node) => node is T): T; function findAncestorNode(match: (node: Node) => boolean): Node; function findAncestorNode(match: (node: Node) => boolean) { - if (parentNode && match(parentNode)) { - return parentNode; - } - for (let i = ancestorStack.length; i >= 0; i--) { - let node = ancestorStack[i]; - if (match(node)) { - return node; - } - } - return undefined; + return nodeStack.findAncestorNode(match); } function isUniqueName(name: string): boolean { @@ -460,7 +419,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function base64VLQFormatEncode(inValue: number) { function base64FormatEncode(inValue: number) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -533,11 +492,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function recordEmitNodeStartSpan(node: Node) { // Get the token pos after skipping to the token (ignoring the leading trivia) - recordSourceMapSpan(skipTrivia(currentSourceFile.text, node.pos)); + if (!nodeIsSynthesized(node)) { + recordSourceMapSpan(skipTrivia(currentSourceFile.text, node.pos)); + } } function recordEmitNodeEndSpan(node: Node) { - recordSourceMapSpan(node.end); + if (!nodeIsSynthesized(node)) { + recordSourceMapSpan(node.end); + } } function writeTextWithSpanRecord(tokenKind: SyntaxKind, startPos: number, emitFn?: () => void) { @@ -751,28 +714,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi sourceMapDir = getDirectoryPath(normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node: Node) { - // node stack behavior: parent of `node` is top of stack. - Debug.assert(currentNode !== node, "Incorrect node stack behavior."); - + function emitNodeWithSourceMapAndWithoutStackBehavior(node: Node) { if (node) { if (nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMapAndWithoutStackBehavior(node); } if (node.kind !== SyntaxKind.SourceFile) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMapAndWithoutStackBehavior(node); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMapAndWithoutStackBehavior(node); } } } - + + function emitNodeWithCommentsAndWithSourcemap(node: Node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMapAndWithoutStackBehavior); + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -928,7 +892,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } } - emitNode(nodes[start + i]); + let node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -1003,7 +974,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } // If we don't need to downlevel and we can reach the original source text using @@ -1016,15 +987,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { case SyntaxKind.StringLiteral: - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); case SyntaxKind.NoSubstitutionTemplateLiteral: - return getQuotedEscapedLiteralText('`', node.text, '`'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case SyntaxKind.TemplateHead: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case SyntaxKind.TemplateMiddle: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("}", node.text, "${"); case SyntaxKind.TemplateTail: - return getQuotedEscapedLiteralText('}', node.text, '`'); + return getQuotedEscapedLiteralText("}", node.text, "`"); case SyntaxKind.NumericLiteral: return node.text; } @@ -1057,7 +1028,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi text = text.replace(/\r\n?/g, "\n"); text = escapeString(text); - write('"' + text + '"'); + write(`"${text}"`); } function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, literalEmitter: (literal: LiteralExpression) => void) { @@ -1100,20 +1071,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Now we emit the expressions if (node.template.kind === SyntaxKind.TemplateExpression) { - pushNode(node.template); - forEach((node.template).templateSpans, templateSpan => { - write(", "); - pushNode(templateSpan); - let needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression - && (templateSpan.expression).operatorToken.kind === SyntaxKind.CommaToken; - emitParenthesizedIf(templateSpan.expression, needsParens); - popNode(); - }); - popNode(); + visitNodeWithPushStackBehavior(node.template, emitTemplateSpansInTemplateExpressionForDownlevelTaggedTemplate); } write("))"); } - + + function emitTemplateSpansInTemplateExpressionForDownlevelTaggedTemplate(node: TemplateExpression) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + forEach(node.templateSpans, emitTemplateSpanForDownlevelTaggedTemplateWithPushStackBehavior); + } + + function emitTemplateSpanForDownlevelTaggedTemplateWithPushStackBehavior(node: TemplateSpan) { + visitNodeWithPushStackBehavior(node, emitTemplateSpanForDownlevelTaggedTemplate); + } + + function emitTemplateSpanForDownlevelTaggedTemplate(node: TemplateSpan) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + write(", "); + let needsParens = node.expression.kind === SyntaxKind.BinaryExpression + && (node.expression).operatorToken.kind === SyntaxKind.CommaToken; + emitParenthesizedIf(node.expression, needsParens); + } + function emitTemplateExpression(node: TemplateExpression): void { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -1123,137 +1102,84 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi forEachChild(node, emit); return; } + + emitTemplateExpressionBelowES6(node); + } + + function emitTemplateExpressionBelowES6(node: TemplateExpression): void { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - let emitOuterParens = isPartOfExpression(parentNode, peekNode, 1) - && templateNeedsParens(node); - + let nav = nodeStack.createParentNavigator(); + nav.moveToParent(); + + let emitOuterParens = isPartOfExpression(nav) && templateNeedsParens(node); if (emitOuterParens) { write("("); } let headEmitted = false; - if (shouldEmitTemplateHead()) { - pushNode(node.head); - emitLiteral(node.head); - popNode(); - + if (shouldEmitTemplateHead(node)) { + visitNodeWithPushStackBehavior(node.head, emitLiteral); headEmitted = true; } for (let i = 0, n = node.templateSpans.length; i < n; i++) { let templateSpan = node.templateSpans[i]; - pushNode(templateSpan); - // Check if the expression has operands and binds its operands less closely than binary '+'. - // If it does, we need to wrap the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - let needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression - && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; - if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's // expression will be the first to be emitted. Don't emit the preceding ' + ' in that // case. write(" + "); } - - emitParenthesizedIf(templateSpan.expression, needsParens); - - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (templateSpan.literal.text.length !== 0) { - write(" + "); - pushNode(templateSpan.literal); - emitLiteral(templateSpan.literal); - popNode(); - } - popNode(); + + visitNodeWithPushStackBehavior(templateSpan, emitTemplateSpanBelowES6); } if (emitOuterParens) { write(")"); } + } + + function shouldEmitTemplateHead(node: TemplateExpression) { + verifyStackBehavior(StackBehavior.Unspecified, node); + + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar - function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + Debug.assert(node.templateSpans.length !== 0); - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - Debug.assert(node.templateSpans.length !== 0); - - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - - function templateNeedsParens(template: TemplateExpression) { - verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, template); - - switch (parentNode.kind) { - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - return (parentNode).expression === template; - case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.ParenthesizedExpression: - return false; - default: - return comparePrecedenceToBinaryPlus(parentNode) !== Comparison.LessThan; - } - } - - /** - * Returns whether the expression has lesser, greater, - * or equal precedence to the binary '+' operator - */ - function comparePrecedenceToBinaryPlus(expression: Expression): Comparison { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' - // which have greater precedence and '-' which has equal precedence. - // All unary operators have a higher precedence apart from yield. - // Arrow functions and conditionals have a lower precedence, - // although we convert the former into regular function expressions in ES5 mode, - // and in ES6 mode this function won't get called anyway. - // - // TODO (drosen): Note that we need to account for the upcoming 'yield' and - // spread ('...') unary operators that are anticipated for ES6. - switch (expression.kind) { - case SyntaxKind.BinaryExpression: - switch ((expression).operatorToken.kind) { - case SyntaxKind.AsteriskToken: - case SyntaxKind.SlashToken: - case SyntaxKind.PercentToken: - return Comparison.GreaterThan; - case SyntaxKind.PlusToken: - case SyntaxKind.MinusToken: - return Comparison.EqualTo; - default: - return Comparison.LessThan; - } - case SyntaxKind.YieldExpression: - case SyntaxKind.ConditionalExpression: - return Comparison.LessThan; - default: - return Comparison.GreaterThan; - } - } + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } + function templateNeedsParens(template: TemplateExpression) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, template); + + let parentNode = nodeStack.getParent(); + switch (parentNode.kind) { + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + return (parentNode).expression === template; + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.ParenthesizedExpression: + return false; + default: + return comparePrecedenceToBinaryPlus(parentNode) !== Comparison.LessThan; + } + } + function emitTemplateSpan(span: TemplateSpan) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, span); @@ -1261,6 +1187,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(span.literal); } + function emitTemplateSpanBelowES6(node: TemplateSpan) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + let needsParens = node.expression.kind !== SyntaxKind.ParenthesizedExpression + && comparePrecedenceToBinaryPlus(node.expression) !== Comparison.GreaterThan; + + emitParenthesizedIf(node.expression, needsParens); + + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (node.literal.text.length !== 0) { + write(" + "); + visitNodeWithPushStackBehavior(node.literal, emitLiteral); + } + } + function jsxEmitReact(node: JsxElement|JsxSelfClosingElement) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -1270,9 +1223,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, name); if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((name).text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -1286,9 +1239,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, name); if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -1308,13 +1261,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("true"); } } + + function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + emit(node.expression); + } + function emitNonEmptyJsxText(node: JsxText) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + let text = getTextToEmit(node); + if (text !== undefined) { + write(", \""); + write(text); + write("\""); + } + } + function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, openingNode); + let syntheticReactRef = createNode(SyntaxKind.Identifier); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); @@ -1328,11 +1301,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // a call to React.__spread let attrs = openingNode.attributes; if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); let haveOpenedObjectLiteral = false; for (let i = 0; i < attrs.length; i++) { - pushNode(attrs[i]); if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) { // If this is the first argument, we need to emit a {} as the first argument if (i === 0) { @@ -1346,7 +1319,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (i > 0) { write(", "); } - emit((attrs[i]).expression); + visitNodeWithPushStackBehavior(attrs[i], emitJsxSpreadAttribute); } else { Debug.assert(attrs[i].kind === SyntaxKind.JsxAttribute); @@ -1360,9 +1333,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } write("{"); } - emitJsxAttribute(attrs[i]); + visitNodeWithPushStackBehavior(attrs[i], emitJsxAttribute); } - popNode(); } if (haveOpenedObjectLiteral) write("}"); @@ -1376,9 +1348,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } - pushNode(attrs[i]); - emitJsxAttribute(attrs[i]); - popNode(); + visitNodeWithPushStackBehavior(attrs[i], emitJsxAttribute); } write("}"); } @@ -1394,14 +1364,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Don't emit empty strings if (children[i].kind === SyntaxKind.JsxText) { - pushNode(children[i]); - let text = getTextToEmit(children[i]); - if(text !== undefined) { - write(', "'); - write(text); - write('"'); - } - popNode(); + visitNodeWithPushStackBehavior(children[i], emitNonEmptyJsxText); } else { write(", "); @@ -1414,7 +1377,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - + if (node.kind === SyntaxKind.JsxElement) { pushNode((node).openingElement); emitJsxElement((node).openingElement, (node).children); @@ -1425,7 +1388,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitJsxElement(node); } } - + function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -1565,6 +1528,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); // + let parentNode = nodeStack.getParent(); if (nodeIsDecorated(parentNode)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -1589,6 +1553,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function isExpressionIdentifier(node: Node): boolean { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + let parentNode = nodeStack.getParent(); switch (parentNode.kind) { case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.BinaryExpression: @@ -1609,6 +1574,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.IfStatement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSpreadAttribute: case SyntaxKind.JsxExpression: case SyntaxKind.NewExpression: case SyntaxKind.ParenthesizedExpression: @@ -1674,7 +1640,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (declaration.kind === SyntaxKind.ImportClause) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === ScriptTarget.ES3 ? '["default"]' : ".default"); + write(languageVersion === ScriptTarget.ES3 ? "[\"default\"]" : ".default"); return; } else if (declaration.kind === SyntaxKind.ImportSpecifier) { @@ -1691,13 +1657,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } } - writeTextOfNode(currentSourceFile, node); + + if (nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node: Identifier) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); if (languageVersion < ScriptTarget.ES6) { + let parentNode = nodeStack.getParent(); let originalNode = getOriginalNode(parentNode); switch (originalNode.kind) { case SyntaxKind.BindingElement: @@ -1722,6 +1695,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -1830,6 +1806,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + let parentNode = nodeStack.getParent(); if (isBinaryExpression(parentNode) && !isAssignmentOperator(parentNode.operatorToken.kind)) { return true; } @@ -2159,6 +2136,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } @@ -2195,12 +2180,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - - let constantValue = resolver.getConstantValue(node); + let constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { @@ -2211,6 +2191,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } + + function tryGetConstEnumValue(node: Node): number { + if (compilerOptions.isolatedModules) { + return undefined; + } + + return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression + ? resolver.getConstantValue(node) + : undefined + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be @@ -2247,10 +2237,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal let shouldEmitSpace: boolean; - if (!indentedBeforeDot && node.expression.kind === SyntaxKind.NumericLiteral) { - let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === SyntaxKind.NumericLiteral) { + // check if numeric literal was originally written with a dot + let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; + } + else { + // check if constant enum value is integer + let constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { @@ -2264,7 +2264,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } - + function emitQualifiedName(node: QualifiedName) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -2291,11 +2291,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { emitEntityNameAsExpression(node.left, /*useFallback*/ false); } - + write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } - + function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { verifyStackBehavior(StackBehavior.Unspecified, node); @@ -2306,10 +2306,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExpressionIdentifier(node); write(" !== 'undefined' && "); } - + emitExpressionIdentifier(node); break; - + case SyntaxKind.QualifiedName: emitQualifiedNameAsExpression(node, useFallback); break; @@ -2510,6 +2510,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. + let parentNode = nodeStack.getParent(); if (!nodeIsSynthesized(node) && parentNode.kind !== SyntaxKind.ArrowFunction) { if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) { let operand = (node.expression).expression; @@ -2578,12 +2579,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return false; } + const parentNode = nodeStack.getNode(); const isVariableDeclarationOrBindingElement = - currentNode && (currentNode.kind === SyntaxKind.VariableDeclaration || currentNode.kind === SyntaxKind.BindingElement); + parentNode && (parentNode.kind === SyntaxKind.VariableDeclaration || parentNode.kind === SyntaxKind.BindingElement); const targetDeclaration = isVariableDeclarationOrBindingElement - ? currentNode + ? parentNode : resolver.getReferencedValueDeclaration(node); return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); @@ -2689,21 +2691,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // node from the checker, so we will be looking at the original source file. // If `node` is not on top of the stack, then we can get the combined node flags // by walking the node stack (preferred). - let followParentReferences = node !== currentNode; - let offset = 0; - let current: Node = node; - while (current) { + let navigable = node !== nodeStack.getNode() ? node : nodeStack; + let nav = navigable.createParentNavigator(); + do { + let current = nav.getNode(); if (current.kind === SyntaxKind.SourceFile) { - let nodeFlags = followParentReferences ? ts.getCombinedNodeFlags(node) : getCombinedNodeFlags(); + let nodeFlags = getCombinedNodeFlags(navigable); return !isExported || ((nodeFlags & NodeFlags.Export) !== 0); } else if (isFunctionLike(current) || current.kind === SyntaxKind.ModuleBlock) { return false; } - else { - current = followParentReferences ? current.parent : peekNode(++offset); - } } + while (nav.moveToParent()); } function emitBinaryExpression(node: BinaryExpression) { @@ -2711,6 +2711,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (languageVersion < ScriptTarget.ES6 && node.operatorToken.kind === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) { + let parentNode = nodeStack.getParent(); emitDestructuring(node, parentNode.kind === SyntaxKind.ExpressionStatement); } else { @@ -2813,6 +2814,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } + let parentNode = nodeStack.getParent(); emitToken(SyntaxKind.OpenBraceToken, node.pos); increaseIndent(); scopeEmitStart(parentNode); @@ -3096,7 +3098,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); @@ -3134,7 +3136,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -3160,7 +3162,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi popNode(); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); @@ -3337,7 +3339,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); emitStart(node.name); - if (getCombinedNodeFlags() & NodeFlags.Export) { + if (getCombinedNodeFlags(nodeStack) & NodeFlags.Export) { let container = getOriginalNode(findAncestorNode(isModuleDeclarationOrGeneratedNamespace)); if (container) { write(getGeneratedNameForNode(container)); @@ -3347,7 +3349,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } @@ -3359,7 +3361,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === ScriptTarget.ES5) { - // default value of configurable, enumerable, writable are `false`. + // default value of configurable, enumerable, writable are `false`. write("Object.defineProperty(exports, \"__esModule\", { value: true });"); writeLine(); } @@ -3380,6 +3382,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitStart(node); // emit call to exporter only for top level nodes + let parentNode = nodeStack.getParent(); if (compilerOptions.module === ModuleKind.System && parentNode === currentSourceFile) { // emit export default as // export("default", ) @@ -3388,7 +3391,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write(`", `); emitDeclarationName(node); @@ -3417,36 +3420,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitExportMemberAssignments(name: Identifier) { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, name); + if (compilerOptions.module === ModuleKind.System) { + return; + } if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { for (let specifier of exportSpecifiers[name.text]) { writeLine(); - if (compilerOptions.module === ModuleKind.System) { - emitStart(specifier.name); - write(`${exportFunctionForFile}("`); - pushNode(specifier); - emitNodeWithoutSourceMap(specifier.name); - popNode(); - write(`", `); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(); - write("."); - pushNode(specifier); - emitNodeWithoutSourceMap(specifier.name); - popNode(); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(); + write("."); + pushNode(specifier); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + popNode(); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + + function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, specifier); + Debug.assert(compilerOptions.module === ModuleKind.System); + + writeLine(); + emitStart(specifier.name); + write(`${exportFunctionForFile}("`); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write(`", `); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, isAssignmentExpressionStatement: boolean, value?: Expression) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, root); @@ -3459,7 +3467,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // because actual variable declarations are hoisted let canDefineTempVariablesInPlace = false; if (root.kind === SyntaxKind.VariableDeclaration) { - let isExported = getCombinedNodeFlags() & NodeFlags.Export; + let isExported = getCombinedNodeFlags(nodeStack) & NodeFlags.Export; let isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -3482,19 +3490,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } + let parentNode = nodeStack.getNode(); const isVariableDeclarationOrBindingElement = - !isTempVariable && (currentNode.kind === SyntaxKind.VariableDeclaration || currentNode.kind === SyntaxKind.BindingElement); + !isTempVariable && (parentNode.kind === SyntaxKind.VariableDeclaration || parentNode.kind === SyntaxKind.BindingElement); let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(`${exportFunctionForFile}("`); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write(`", `); } if (isVariableDeclarationOrBindingElement) { - emitModuleMemberName(currentNode); + emitModuleMemberName(parentNode); } else { emit(name); @@ -3603,6 +3612,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitDestructuringAssignment(target, value); } else { + let parentNode = nodeStack.getParent(); if (parentNode.kind !== SyntaxKind.ParenthesizedExpression) { write("("); } @@ -3692,7 +3702,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet) { - let grandparent = peekNode(2); + let grandparent = nodeStack.getGrandparent(); if (grandparent.kind !== SyntaxKind.ForInStatement && grandparent.kind !== SyntaxKind.ForOfStatement) { initializer = factory.createVoidZeroExpression(); @@ -3701,10 +3711,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + visitNodeWithPushStackBehavior if (exportChanged) { write(`${exportFunctionForFile}("`); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write(`", `); } @@ -3739,19 +3750,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi popNode(); } - function getCombinedNodeFlags(): NodeFlags { - return ts.getCombinedNodeFlags(currentNode, peekNode, 0); - } - function getCombinedFlagsForIdentifier(name: Identifier): NodeFlags { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, name); - let parent = currentNode; - if (!parent || (parent.kind !== SyntaxKind.VariableDeclaration && parent.kind !== SyntaxKind.BindingElement)) { + let parentNode = nodeStack.getNode(); + if (!parentNode || (parentNode.kind !== SyntaxKind.VariableDeclaration && parentNode.kind !== SyntaxKind.BindingElement)) { return 0; } - return getCombinedNodeFlags(); + return getCombinedNodeFlags(nodeStack); } function isES6ExportedDeclaration(node: Node) { @@ -3759,7 +3766,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return !!(node.flags & NodeFlags.Export) && languageVersion >= ScriptTarget.ES6 && - parentNode.kind === SyntaxKind.SourceFile; + nodeStack.getParent().kind === SyntaxKind.SourceFile; } function emitVariableStatement(node: VariableStatement) { @@ -3798,7 +3805,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - if (languageVersion < ScriptTarget.ES6 && parentNode === currentSourceFile) { + if (languageVersion < ScriptTarget.ES6 && nodeStack.getParent() === currentSourceFile) { pushNode(declarationList); forEach(declarationList.declarations, emitExportVariableAssignmentsOfChild); popNode(); @@ -3899,9 +3906,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -3928,7 +3935,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -3949,7 +3956,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -3977,7 +3984,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); @@ -4005,11 +4012,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } - if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature && + node.parent && node.parent.kind !== SyntaxKind.PropertyAssignment && + node.parent.kind !== SyntaxKind.CallExpression) { + // 1. Methods will emit the comments as part of emitting method declaration + + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(node); // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -4032,9 +4056,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } emitSignatureAndBody(node); - if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && parentNode === currentSourceFile && node.name) { + if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && nodeStack.getParent() === currentSourceFile && node.name) { emitExportMemberAssignments((node).name); } + + emitEnd(node); if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { emitTrailingComments(node); } @@ -4428,10 +4454,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, member); let memberName = member.name; - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } else if (memberName.kind === SyntaxKind.ComputedPropertyName) { @@ -4443,7 +4471,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } @@ -4529,10 +4557,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitMemberAccessForPropertyName(member); emitEnd((member).name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); popNode(); @@ -4735,18 +4761,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // any other preamble code we write (like parameter initializers). pushNode(ctor); pushNode(ctor.body); - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); popNode(); popNode(); } emitCaptureThisForNodeIfNecessary(node); + let superCall: ExpressionStatement; if (ctor) { pushNode(ctor); emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); pushNode(ctor.body); @@ -5078,7 +5105,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportMemberAssignment(node); } - if (languageVersion < ScriptTarget.ES6 && parentNode === currentSourceFile && node.name) { + if (languageVersion < ScriptTarget.ES6 && nodeStack.getParent() === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } @@ -5385,7 +5412,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } - + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ function emitSerializedTypeOfNode(node: Node) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -5398,42 +5425,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { case SyntaxKind.ClassDeclaration: write("Function"); return; - + case SyntaxKind.PropertyDeclaration: emitSerializedTypeNode((node).type); return; - + case SyntaxKind.Parameter: emitSerializedTypeNode((node).type); return; - + case SyntaxKind.GetAccessor: emitSerializedTypeNode((node).type); return; - + case SyntaxKind.SetAccessor: emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(node)); return; - + } - + if (isFunctionLike(node)) { write("Function"); return; } - + write("void 0"); } function emitSerializedTypeNode(node: TypeNode) { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, node); + if (!node) { + return; + } + switch (node.kind) { case SyntaxKind.VoidKeyword: write("void 0"); @@ -5444,17 +5475,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitSerializedTypeNode((node).type); popNode(); return; - + case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: write("Function"); return; - + case SyntaxKind.ArrayType: case SyntaxKind.TupleType: write("Array"); return; - + case SyntaxKind.TypePredicate: case SyntaxKind.BooleanKeyword: write("Boolean"); @@ -5464,11 +5495,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.StringLiteral: write("String"); return; - + case SyntaxKind.NumberKeyword: write("Number"); return; - + case SyntaxKind.SymbolKeyword: write("Symbol"); return; @@ -5478,34 +5509,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitSerializedTypeReferenceNode(node); popNode(); return; - + case SyntaxKind.TypeQuery: case SyntaxKind.TypeLiteral: case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: case SyntaxKind.AnyKeyword: break; - + default: Debug.fail("Cannot serialize unexpected type node."); break; } - + write("Object"); } - + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node: TypeReferenceNode) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - let typeName = node.typeName; - let result = resolver.getTypeReferenceSerializationKind(node); + let location: Node = node.parent; + while (isDeclaration(location) || isTypeNode(location)) { + location = location.parent; + } + + // Clone the type name and parent it to a location outside of the current declaration. + let typeName = cloneEntityName(node.typeName); + typeName.parent = location; + + let result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case TypeReferenceSerializationKind.Unknown: let temp = createAndRecordTempVariable(TempFlags.Auto); write("(typeof ("); emitNodeWithoutSourceMap(temp); - write(" = ") + write(" = "); emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); @@ -5515,27 +5554,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; - + case TypeReferenceSerializationKind.VoidType: write("void 0"); break; - + case TypeReferenceSerializationKind.BooleanType: write("Boolean"); break; - + case TypeReferenceSerializationKind.NumberLikeType: write("Number"); break; - + case TypeReferenceSerializationKind.StringLikeType: write("String"); break; - + case TypeReferenceSerializationKind.ArrayLikeType: write("Array"); break; - + case TypeReferenceSerializationKind.ESSymbolType: if (languageVersion < ScriptTarget.ES6) { write("typeof Symbol === 'function' ? Symbol : Object"); @@ -5544,17 +5583,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("Symbol"); } break; - + case TypeReferenceSerializationKind.TypeWithCallSignature: write("Function"); break; - + case TypeReferenceSerializationKind.ObjectType: write("Object"); break; } } - + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ function emitSerializedParameterTypesOfNode(node: Node) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -5563,63 +5602,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { - var valueDeclaration: FunctionLikeDeclaration; + let valueDeclaration: FunctionLikeDeclaration; if (node.kind === SyntaxKind.ClassDeclaration) { valueDeclaration = getFirstConstructorWithBody(node); } else if (isFunctionLike(node) && nodeIsPresent((node).body)) { valueDeclaration = node; } - + if (valueDeclaration) { - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - if (i > 0) { - write(", "); - } - - let parameter = parameters[i]; - pushNode(parameter); - if (parameter.dotDotDotToken) { - var parameterType = parameter.type; - if (parameterType.kind === SyntaxKind.ArrayType) { - parameterType = (parameterType).elementType; - } - else if (parameterType.kind === SyntaxKind.TypeReference && (parameterType).typeArguments && (parameterType).typeArguments.length === 1) { - parameterType = (parameterType).typeArguments[0]; - } - else { - parameterType = undefined; + const parameters = valueDeclaration.parameters; + const parameterCount = parameters.length; + if (parameterCount > 0) { + for (var i = 0; i < parameterCount; i++) { + if (i > 0) { + write(", "); } - emitSerializedTypeNode(parameterType); + let parameter = parameters[i]; + if (parameter.dotDotDotToken) { + let parameterType = parameters[i].type; + if (parameterType.kind === SyntaxKind.ArrayType) { + parameterType = (parameterType).elementType; + } + else if (parameterType.kind === SyntaxKind.TypeReference && (parameterType).typeArguments && (parameterType).typeArguments.length === 1) { + parameterType = (parameterType).typeArguments[0]; + } + else { + parameterType = undefined; + } + + visitNodeWithPushStackBehavior(parameterType, emitSerializedTypeNode); + } + else { + visitNodeWithPushStackBehavior(parameters[i], emitSerializedTypeOfNode); + } } - else { - emitSerializedTypeOfNode(parameter); - } - popNode(); } } } } - + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node: Node): string | string[] { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - if (node && isFunctionLike(node)) { + if (node && isFunctionLike(node) && (node).type) { emitSerializedTypeNode((node).type); return; } - + write("void 0"); } - - + + function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -5651,7 +5690,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (writeComma || argumentsWritten) { write(", "); } - + writeLine(); write("__metadata('design:returntype', "); emitSerializedReturnTypeOfNode(node); @@ -5659,10 +5698,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi argumentsWritten++; } } - + return argumentsWritten; } - + function emitInterfaceDeclaration(node: InterfaceDeclaration) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -5729,7 +5768,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitEnd(node); write(";"); } - if (languageVersion < ScriptTarget.ES6 && parentNode === currentSourceFile) { + if (languageVersion < ScriptTarget.ES6 && nodeStack.getParent() === currentSourceFile) { if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { // write the call to exporter for enum writeLine(); @@ -5746,7 +5785,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitEnumMember(node: EnumMember) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - let enumParent = parentNode; + let enumParent = nodeStack.getParent(); emitStart(node); write(getGeneratedNameForNode(enumParent)); write("["); @@ -5867,7 +5906,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && parentNode === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && nodeStack.getParent() === currentSourceFile) { if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { writeLine(); write(`${exportFunctionForFile}("`); @@ -5879,17 +5918,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportMemberAssignments(node.name); } } + + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName: LiteralExpression): string { + if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return `"${currentSourceFile.renamedDependencies[moduleName.text]}"` + } + return undefined; + } function emitRequire(moduleName: Expression) { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, moduleName); if (moduleName.kind === SyntaxKind.StringLiteral) { write("require("); - emitStart(moduleName); - pushNode(moduleName); - emitLiteral(moduleName); - popNode(); - emitEnd(moduleName); + let text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + pushNode(moduleName); + emitLiteral(moduleName); + popNode(); + emitEnd(moduleName); + } emitToken(SyntaxKind.CloseParenToken, moduleName.end); } else { @@ -6096,18 +6152,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - + // variable declaration for import-equals declaration can be hoisted in system modules // in this case 'var' should be omitted and emit should contain only initialization let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - + // is it top level export import v = a.b.c in system module? // if yes - it needs to be rewritten as exporter('v', v = a.b.c) let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - + if (!variableDeclarationIsHoisted) { Debug.assert(!isExported); - + if (isES6ExportedDeclaration(node)) { write("export "); write("var "); @@ -6116,8 +6172,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("var "); } } - - + + if (isExported) { write(`${exportFunctionForFile}("`); emitNodeWithoutSourceMap(node.name); @@ -6131,8 +6187,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (isExported) { write(")"); } - - write(";"); + + write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); @@ -6163,11 +6219,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitStart(specifier); emitContainingModuleName(); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -6190,7 +6246,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -6205,10 +6260,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -6224,13 +6278,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -6345,6 +6397,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("}"); } } + + function getLocalNameForExternalImportWithPushStackBehavior(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { + verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, node); + pushNode(node); + let result = getLocalNameForExternalImport(node); + popNode(); + return result; + } function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -6366,7 +6426,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let moduleName = getExternalModuleName(importNode); if (moduleName.kind === SyntaxKind.StringLiteral) { - return getLiteralText(moduleName); + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; @@ -6399,9 +6459,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); } - pushNode(importNode); - write(getLocalNameForExternalImport(importNode)); - popNode(); + write(getLocalNameForExternalImportWithPushStackBehavior(importNode)); } if (started) { @@ -6519,7 +6577,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); write("}"); writeLine(); - write(`${exportFunctionForFile}(exports);`) + write(`${exportFunctionForFile}(exports);`); decreaseIndent(); writeLine(); write("}"); @@ -6546,7 +6604,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); write("'"); if (node.kind === SyntaxKind.Identifier) { - emitNodeWithoutSourceMap(node); + emitNodeWithCommentsAndWithoutSourcemap(node); } else { pushNode(node); @@ -6645,7 +6703,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitDeclarationName(node); - let flags = getCombinedNodeFlags(); + let flags = getCombinedNodeFlags(nodeStack); if (flags & NodeFlags.Export) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -6664,10 +6722,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + function shouldHoistNode(node: Node): node is Declaration { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - + switch (node.kind) { case SyntaxKind.ClassDeclaration: return true; @@ -6698,15 +6756,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (getCombinedNodeFlags() & NodeFlags.BlockScoped) === 0 || - getEnclosingBlockScopeContainer(node, peekNode, /*offset*/ 0).kind === SyntaxKind.SourceFile; + return (getCombinedNodeFlags(nodeStack) & NodeFlags.BlockScoped) === 0 || + getEnclosingBlockScopeContainer(nodeStack).kind === SyntaxKind.SourceFile; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === ModuleKind.System && isExternalModule(currentSourceFile); } - function emitSystemModuleBody(statements: NodeArray, startIndex: number): void { + function emitSystemModuleBody(statements: NodeArray, dependencyGroups: DependencyGroup[], startIndex: number): void { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack); // shape of the body in system modules: @@ -6753,7 +6811,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(statements, startIndex); decreaseIndent(); @@ -6762,141 +6820,98 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction: string) { + function emitSetters(exportStarFunction: string, dependencyGroups: DependencyGroup[]) { verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack); write("setters:["); - for (let i = 0; i < externalImports.length; ++i) { + + for (let i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - - let importNode = externalImports[i]; - pushNode(importNode); - let importVariableName = getLocalNameForExternalImport(importNode) || ""; - let parameterName = "_" + importVariableName; + let group = dependencyGroups[i]; + + // derive a unique name for parameter from the first named entry in the group + let parameterName = makeUniqueName(forEach(group, getLocalNameForExternalImportWithPushStackBehavior) || ""); write(`function (${parameterName}) {`); - - switch (importNode.kind) { - case SyntaxKind.ImportDeclaration: - if (!(importNode).importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - - // fall-through - case SyntaxKind.ImportEqualsDeclaration: - Debug.assert(importVariableName !== ""); - - increaseIndent(); - writeLine(); - // save import into the local - write(`${importVariableName} = ${parameterName};`); - writeLine(); - - let defaultName = - importNode.kind === SyntaxKind.ImportDeclaration - ? (importNode).importClause.name - : (importNode).name; - - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - if (importNode.kind === SyntaxKind.ImportDeclaration) { - pushNode((importNode).importClause); + increaseIndent(); + + for(let entry of group) { + let importVariableName = getLocalNameForExternalImportWithPushStackBehavior(entry) || ""; + + switch (entry.kind) { + case SyntaxKind.ImportDeclaration: + if (!(entry).importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; } - - emitExportMemberAssignments(defaultName); + // fall-through + case SyntaxKind.ImportEqualsDeclaration: + Debug.assert(importVariableName !== ""); + writeLine(); - - if (importNode.kind === SyntaxKind.ImportDeclaration) { - popNode(); - } - } + // save import into the local + write(`${importVariableName} = ${parameterName};`); + writeLine(); + break; + case SyntaxKind.ExportDeclaration: + Debug.assert(importVariableName !== ""); - if (importNode.kind === SyntaxKind.ImportDeclaration && - (importNode).importClause.namedBindings) { - pushNode((importNode).importClause); - let namedBindings = (importNode).importClause.namedBindings; - pushNode(namedBindings); - if (namedBindings.kind === SyntaxKind.NamespaceImport) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments((namedBindings).name); + if ((entry).exportClause) { + pushNode((entry).exportClause); + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); - } - else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (let element of (namedBindings).elements) { - pushNode(element); - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); + write(`${exportFunctionForFile}({`); + writeLine(); + increaseIndent(); + for (let i = 0, len = (entry).exportClause.elements.length; i < len; ++i) { + if (i !== 0) { + write(","); + writeLine(); + } + + let e = (entry).exportClause.elements[i]; + pushNode(e); + write(`"`); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write(`": ${parameterName}["`); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write(`"]`); popNode(); } - } - popNode(); - popNode(); - } - - decreaseIndent(); - break; - case SyntaxKind.ExportDeclaration: - Debug.assert(importVariableName !== ""); - - increaseIndent(); - - if ((importNode).exportClause) { - pushNode((importNode).exportClause); - // export {a, b as c} from 'foo' - // emit as: - // var reexports = {} - // reexports['a'] = _foo["a"]; - // reexports['c'] = _foo["b"]; - // exports_(reexports); - let reexportsVariableName = makeUniqueName("reexports"); - writeLine(); - write(`var ${reexportsVariableName} = {};`) - writeLine(); - for (let e of (importNode).exportClause.elements) { - pushNode(e); - write(`${reexportsVariableName}["`); - emitNodeWithoutSourceMap(e.name); - write(`"] = ${parameterName}["`); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write(`"];`); - writeLine(); popNode(); + decreaseIndent(); + writeLine(); + write("});") + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(`${exportStarFunction}(${parameterName});`); } - write(`${exportFunctionForFile}(${reexportsVariableName});`); - popNode(); - } - else { - writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(`${exportStarFunction}(${parameterName});`); - } - writeLine(); - decreaseIndent(); - break; + writeLine(); + break; + } + } + decreaseIndent(); + write("}"); decreaseIndent(); - popNode(); } write("],"); } @@ -6909,26 +6924,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); for (let i = startIndex; i < statements.length; ++i) { let statement = statements[i]; - // - external module related imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case SyntaxKind.ExportDeclaration: - case SyntaxKind.ImportDeclaration: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ImportDeclaration: + continue; + case SyntaxKind.ExportDeclaration: + if (!(statement).moduleSpecifier) { + pushNode(statement); + pushNode((statement).exportClause); + for (let element of (statement).exportClause.elements) { + // write call to exporter function for every export specifier in exports list + pushNode(element); + emitExportSpecifierInSystemModule(element); + popNode(); + } + popNode(); + popNode(); + } continue; case SyntaxKind.ImportEqualsDeclaration: if (!isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted continue; } - } - writeLine(); - emit(statement); + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); + } } decreaseIndent(); writeLine(); write("}"); // execute } - + + type DependencyGroup = Array; + function emitSystemModule(node: SourceFile, statements: NodeArray, startIndex: number): void { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); @@ -6950,21 +6985,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(`"${node.moduleName}", `); } write("["); + + let groupIndices: Map = {}; + let dependencyGroups: DependencyGroup[] = []; + for (let i = 0; i < externalImports.length; ++i) { let externalImport = externalImports[i]; pushNode(externalImport); let text = getExternalModuleNameText(externalImport); + popNode(); + if (hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + let groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImport]); + } + if (i !== 0) { write(", "); } + write(text); - popNode(); } + write(`], function(${exportFunctionForFile}) {`); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(statements, startIndex); + emitSystemModuleBody(statements, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -7040,6 +7093,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitAMDModule(node: SourceFile, statements: NodeArray, startIndex: number) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); @@ -7063,6 +7117,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitCommonJSModule(node: SourceFile, statements: NodeArray, startIndex: number) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -7074,6 +7129,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitUMDModule(node: SourceFile, statements: NodeArray, startIndex: number) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader @@ -7105,6 +7161,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(statements, startIndex); emitTempDeclarations(/*newLine*/ true); @@ -7142,11 +7199,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function trimReactWhitespace(node: JsxText): string { + function trimReactWhitespaceAndApplyEntities(node: JsxText): string { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); let result: string = undefined; - let text = getTextOfNode(node); + let text = getTextOfNode(node, /*includeTrivia*/ true); let firstNonWhitespace = 0; let lastNonWhitespace = -1; @@ -7158,7 +7215,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -7169,9 +7226,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + if (firstNonWhitespace !== -1) { let part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function(s: any, m: string) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; @@ -7182,8 +7252,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi switch (compilerOptions.jsx) { case JsxEmit.React: - let text = trimReactWhitespace(node); - if (text.length === 0) { + let text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -7191,7 +7261,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } case JsxEmit.Preserve: default: - return getTextOfNode(node, true); + return getTextOfNode(node, /*includeTrivia*/ true); } } @@ -7200,14 +7270,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi switch (compilerOptions.jsx) { case JsxEmit.React: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case JsxEmit.Preserve: default: // Emit JSX-preserve as default when no --jsx flag is specified - write(getTextOfNode(node, true)); + writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -7219,9 +7289,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi switch (compilerOptions.jsx) { case JsxEmit.Preserve: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case JsxEmit.React: emit(node.expression); @@ -7261,21 +7331,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function emitSourceFileNode(node: SourceFile) { + function emitEmitHelpers(node: SourceFile): void { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - - // Start new file on new line - writeLine(); - emitDetachedComments(node); - - // Process tree transformations - let statements = node.statements; - if (compilerOptions.experimentalTransforms) { - statements = runTransformationChain(statements, transformationChain, compilerOptions, currentSourceFile, resolver, generatedNameSet, nodeToGeneratedName); - } - - // emit prologue directives prior to __extends - let startIndex = emitDirectivePrologues(statements, /*startWithNewLine*/ false); // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { @@ -7304,6 +7361,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi awaiterEmitted = true; } } + } + + function emitSourceFileNode(node: SourceFile) { + verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + + // Process tree transformations + let statements = node.statements; + if (compilerOptions.experimentalTransforms) { + statements = runTransformationChain(statements, transformationChain, compilerOptions, currentSourceFile, resolver, generatedNameSet, nodeToGeneratedName); + } + + // emit prologue directives prior to __extends + let startIndex = emitDirectivePrologues(statements, /*startWithNewLine*/ false); if (isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= ScriptTarget.ES6) { @@ -7327,52 +7402,79 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(statements, startIndex); emitTempDeclarations(/*newLine*/ true); } - pushNode(node.endOfFileToken); - emitLeadingComments(node.endOfFileToken); - popNode(); + visitNodeWithPushStackBehavior(node.endOfFileToken, emitLeadingComments); + } + + function visitNodeWithPushStackBehavior(node: T, visit: (node: T) => U): U; + function visitNodeWithPushStackBehavior(node: T, pipe: (node: T, emitNode: (node: T) => U) => U, visit?: (node: T) => U): U; + function visitNodeWithPushStackBehavior(node: T, pipe: (node: T, emitNode?: (node: T) => U) => U, visit?: (node: T) => U): U { + let result: U; + if (node) { + verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, node); + pushNode(node); + result = visit ? pipe(node, visit) : pipe(node); + popNode(); + } + + return result; + } + + function emitNodeWithCommentsAndWithoutSourcemap(node: Node): void { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMapAndWithoutStackBehavior); + } + + function emitNodeConsideringCommentsOption(node: Node, emitNodeConsideringSourcemapWithoutStackBehavior: (node: Node) => void): void { + if (node) { + verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, node); + + if (node.flags & NodeFlags.Ambient || isMissingDeclaration(node)) { + return visitNodeWithPushStackBehavior(node, emitOnlyPinnedOrTripleSlashComments); + } + + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + + visitNodeWithPushStackBehavior(node, emitNodeWithCommentsAndWithoutStackBehavior, emitNodeConsideringSourcemapWithoutStackBehavior); + } + } + + function emitNodeWithCommentsAndWithoutStackBehavior(node: Node, emitNodeConsideringSourcemapWithoutStackBehavior: (node: Node) => void): void { + verifyStackBehavior(StackBehavior.Unspecified, node); + + let emitComments = shouldEmitLeadingAndTrailingComments(node); + if (emitComments) { + emitLeadingComments(node); + } + + emitNodeConsideringSourcemapWithoutStackBehavior(node); + + if (emitComments) { + emitTrailingComments(node); + } } function emitNodeWithoutSourceMap(node: Node): void { - if (!node) { - return; + if (node) { + visitNodeWithPushStackBehavior(node, emitNodeWithoutSourceMapAndWithoutStackBehavior); } - - verifyStackBehavior(StackBehavior.ParentIsOnTopOfStack, node); - let debugStackSize = nodeStackSize; - let debugParentNode = parentNode; - let debugCurrentNode = currentNode; - - pushNode(node); - if (node.flags & NodeFlags.Ambient || isMissingDeclaration(node)) { - emitOnlyPinnedOrTripleSlashComments(node); - } - else { - let emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - + } + + function emitNodeWithoutSourceMapAndWithoutStackBehavior(node: Node): void { + if (node) { emitJavaScriptWorker(node); - - if (emitComments) { - emitTrailingComments(node); - } } - - popNode(); - - Debug.assert(debugStackSize === nodeStackSize - && debugParentNode === parentNode - && debugCurrentNode === currentNode, "Incorrect stack behavior. Node stack after emit does not match node stack before emit."); } - function shouldEmitLeadingAndTrailingComments(node: Node) { - verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); + function isSpecializedCommentHandling(node: Node): boolean { + verifyStackBehavior(StackBehavior.Unspecified, node); switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow @@ -7383,8 +7485,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ExportAssignment: - return false; + return true; + } + } + function shouldEmitLeadingAndTrailingComments(node: Node) { + switch (node.kind) { case SyntaxKind.VariableStatement: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); @@ -7399,10 +7505,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + Debug.assert(!isSpecializedCommentHandling(node)); + // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. + let parentNode = nodeStack.getParent(); if (node.kind !== SyntaxKind.Block && parentNode && parentNode.kind === SyntaxKind.ArrowFunction && @@ -7611,6 +7722,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] { verifyStackBehavior(StackBehavior.Unspecified); @@ -7629,13 +7745,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getLeadingCommentsToEmit(node: Node) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - if (nodeIsSynthesized(node)) { - return (node).leadingCommentRanges; - } - - //node = getOriginalNode(node); - // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + let parentNode = nodeStack.getParent(); if (parentNode) { if (parentNode.kind === SyntaxKind.SourceFile || node.pos !== parentNode.pos) { if (hasDetachedComments(node.pos)) { @@ -7653,13 +7764,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getTrailingCommentsToEmit(node: Node) { verifyStackBehavior(StackBehavior.NodeIsOnTopOfStack, node); - if (nodeIsSynthesized(node)) { - return (node).trailingCommentRanges; - } - - //node = getOriginalNode(node); - // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + let parentNode = nodeStack.getParent(); if (parentNode && !nodeIsSynthesized(parentNode)) { if (parentNode.kind === SyntaxKind.SourceFile || node.end !== parentNode.end) { return getTrailingCommentRanges(currentSourceFile.text, node.end); @@ -7702,6 +7808,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); } + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos: number) { + let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos: number) { verifyStackBehavior(StackBehavior.Unspecified); @@ -7768,6 +7886,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + + function emitShebang() { + let shebang = getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); + } + } function isPinnedOrTripleSlashComment(comment: CommentRange) { verifyStackBehavior(StackBehavior.Unspecified); @@ -7786,6 +7911,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function verifyStackBehavior(behavior: StackBehavior, node?: Node) { + let currentNode = nodeStack.getNode(); switch (behavior) { case StackBehavior.Unspecified: return; @@ -7814,4 +7940,260 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + + var entities: Map = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e5a2b0ea758..0cf0d7f4dc6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -835,6 +835,10 @@ namespace ts { return token = scanner.scanJsxIdentifier(); } + function scanJsxText(): SyntaxKind { + return token = scanner.scanJsxToken(); + } + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -904,9 +908,11 @@ namespace ts { return token > SyntaxKind.LastReservedWord; } - function parseExpected(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage): boolean { + function parseExpected(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage, shouldAdvance = true): boolean { if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } @@ -3169,7 +3175,7 @@ namespace ts { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -3299,14 +3305,14 @@ namespace ts { return finishNode(node); } - function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { - let opening = parseJsxOpeningOrSelfClosingElement(); + function parseJsxElementOrSelfClosingElement(inExpressionContext: boolean): JsxElement | JsxSelfClosingElement { + let opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); if (opening.kind === SyntaxKind.JsxOpeningElement) { let node = createNode(SyntaxKind.JsxElement, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { @@ -3327,9 +3333,9 @@ namespace ts { case SyntaxKind.JsxText: return parseJsxText(); case SyntaxKind.OpenBraceToken: - return parseJsxExpression(); + return parseJsxExpression(/*inExpressionContext*/ false); case SyntaxKind.LessThanToken: - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } Debug.fail("Unknown JSX child kind " + token); } @@ -3359,7 +3365,7 @@ namespace ts { return result; } - function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext: boolean): JsxOpeningElement|JsxSelfClosingElement { let fullStart = scanner.getStartPos(); parseExpected(SyntaxKind.LessThanToken); @@ -3369,12 +3375,22 @@ namespace ts { let attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); let node: JsxOpeningLikeElement; - if (parseOptional(SyntaxKind.GreaterThanToken)) { + if (token === SyntaxKind.GreaterThanToken) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors node = createNode(SyntaxKind.JsxOpeningElement, fullStart); + scanJsxText(); } else { parseExpected(SyntaxKind.SlashToken); - parseExpected(SyntaxKind.GreaterThanToken); + if (inExpressionContext) { + parseExpected(SyntaxKind.GreaterThanToken); + } + else { + parseExpected(SyntaxKind.GreaterThanToken, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } node = createNode(SyntaxKind.JsxSelfClosingElement, fullStart); } @@ -3397,14 +3413,20 @@ namespace ts { return elementName; } - function parseJsxExpression(): JsxExpression { + function parseJsxExpression(inExpressionContext: boolean): JsxExpression { let node = createNode(SyntaxKind.JsxExpression); parseExpected(SyntaxKind.OpenBraceToken); if (token !== SyntaxKind.CloseBraceToken) { node.expression = parseExpression(); } - parseExpected(SyntaxKind.CloseBraceToken); + if (inExpressionContext) { + parseExpected(SyntaxKind.CloseBraceToken); + } + else { + parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } @@ -3423,7 +3445,7 @@ namespace ts { node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } @@ -3439,11 +3461,17 @@ namespace ts { return finishNode(node); } - function parseJsxClosingElement(): JsxClosingElement { + function parseJsxClosingElement(inExpressionContext: boolean): JsxClosingElement { let node = createNode(SyntaxKind.JsxClosingElement); parseExpected(SyntaxKind.LessThanSlashToken); node.tagName = parseJsxElementName(); - parseExpected(SyntaxKind.GreaterThanToken); + if (inExpressionContext) { + parseExpected(SyntaxKind.GreaterThanToken); + } + else { + parseExpected(SyntaxKind.GreaterThanToken, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } @@ -4904,12 +4932,15 @@ namespace ts { function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + let namespaceFlag = flags & NodeFlags.Namespace; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -5794,7 +5825,6 @@ namespace ts { if (!name) { parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected); - return undefined; } let preName: Identifier, postName: Identifier; @@ -6479,4 +6509,4 @@ namespace ts { Value = -1 } } -} \ No newline at end of file +} diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 412e28a8c4b..18f6f3ad8e7 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1,5 +1,6 @@ /// /// +/// namespace ts { /* @internal */ export let programTime = 0; @@ -8,7 +9,10 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - export const version = "1.6.0"; + + let emptyArray: any[] = []; + + export const version = "1.7.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; @@ -25,6 +29,211 @@ namespace ts { } return undefined; } + + export function resolveTripleslashReference(moduleName: string, containingFile: string): string { + let basePath = getDirectoryPath(containingFile); + let referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName); + return normalizePath(referencedFileName); + } + + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { + let moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; + + switch (moduleResolution) { + case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host); + case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + + export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule { + let containingDirectory = getDirectoryPath(containingFile); + + if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + let failedLookupLocations: string[] = []; + let candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + + if (resolvedFileName) { + return { resolvedFileName, failedLookupLocations }; + } + + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return { resolvedFileName, failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + + function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return forEach(supportedExtensions, tryLoad); + } + + function tryLoad(ext: string): string { + let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + + function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + let packageJsonPath = combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + + let jsonContent: { typings?: string }; + + try { + let jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + + if (jsonContent.typings) { + let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + + return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + + function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModule { + let failedLookupLocations: string[] = []; + directory = normalizeSlashes(directory); + while (true) { + let baseName = getBaseFileName(directory); + if (baseName !== "node_modules") { + let nodeModulesFolder = combinePaths(directory, "node_modules"); + let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations }; + } + + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedFileName: result, failedLookupLocations }; + } + } + + let parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + + directory = parentPath; + } + + return { resolvedFileName: undefined, failedLookupLocations }; + } + + export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule { + Debug.assert(baseUrl !== undefined); + + let normalizedModuleName = normalizeSlashes(moduleName); + let basePart = useBaseUrl(moduleName) ? baseUrl : getDirectoryPath(containingFile); + let candidate = normalizePath(combinePaths(basePart, moduleName)); + + let failedLookupLocations: string[] = []; + + return forEach(supportedExtensions, ext => tryLoadFile(candidate + ext)) || { resolvedFileName: undefined, failedLookupLocations }; + + function tryLoadFile(location: string): ResolvedModule { + if (host.fileExists(location)) { + return { resolvedFileName: location, failedLookupLocations }; + } + else { + failedLookupLocations.push(location); + return undefined; + } + } + } + + function nameStartsWithDotSlashOrDotDotSlash(name: string) { + let i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot); + } + + function useBaseUrl(moduleName: string): boolean { + // path is not rooted + // module name does not start with './' or '../' + return getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName); + } + + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { + + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + + let searchPath = getDirectoryPath(containingFile); + let searchName: string; + + let failedLookupLocations: string[] = []; + + let referencedSourceFile: string; + while (true) { + searchName = normalizePath(combinePaths(searchPath, moduleName)); + referencedSourceFile = forEach(supportedExtensions, extension => { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + + let candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + + if (referencedSourceFile) { + break; + } + + let parentPath = getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + + return { resolvedFileName: referencedSourceFile, failedLookupLocations }; + } + + /* @internal */ + export const defaultInitCompilerOptions: CompilerOptions = { + module: ModuleKind.CommonJS, + target: ScriptTarget.ES3, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false, + }; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { let currentDirectory: string; @@ -92,7 +301,8 @@ namespace ts { } const newLine = getNewLineCharacter(options); - + + return { getSourceFile, getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)), @@ -100,7 +310,9 @@ namespace ts { getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, getCanonicalFileName, - getNewLine: () => newLine + getNewLine: () => newLine, + fileExists: fileName => sys.fileExists(fileName), + readFile: fileName => sys.readFile(fileName) }; } @@ -143,7 +355,7 @@ namespace ts { } } - export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program { + export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; let diagnostics = createDiagnosticCollection(); @@ -158,24 +370,46 @@ namespace ts { let start = new Date().getTime(); host = host || createCompilerHost(options); + + const resolveModuleNamesWorker = + host.resolveModuleNames || + ((moduleNames, containingFile) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedFileName)); let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); - - forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false)); - - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true); + + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + let oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + + if (!tryReuseStructureFromOldProgram()) { + forEach(rootNames, name => processRootFile(name, false)); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; + programTime += new Date().getTime() - start; program = { + getRootFileNames: () => rootNames, getSourceFile: getSourceFile, getSourceFiles: () => files, getCompilerOptions: () => options, @@ -211,6 +445,82 @@ namespace ts { return classifiableNames; } + function tryReuseStructureFromOldProgram(): boolean { + if (!oldProgram) { + return false; + } + + Debug.assert(!oldProgram.structureIsReused); + + // there is an old program, check if we can reuse its structure + let oldRootNames = oldProgram.getRootFileNames(); + if (!arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + + // check if program source files has changed in the way that can affect structure of the program + let newSourceFiles: SourceFile[] = []; + for (let oldSourceFile of oldProgram.getSourceFiles()) { + let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + + // check tripleslash references + if (!arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + + // check imports + collectExternalModuleReferences(newSourceFile); + if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + + if (resolveModuleNamesWorker) { + let moduleNames = map(newSourceFile.imports, name => name.text); + let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (let i = 0; i < moduleNames.length; ++i) { + let oldResolution = getResolvedModuleFileName(oldSourceFile, moduleNames[i]); + if (oldResolution !== resolutions[i]) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + + // update fileName -> file mapping + for (let file of newSourceFiles) { + filesByName.set(file.fileName, file); + } + + files = newSourceFiles; + + oldProgram.structureIsReused = true; + + return true; + } + function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost { return { getCanonicalFileName: fileName => host.getCanonicalFileName(fileName), @@ -253,7 +563,7 @@ namespace ts { // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out)? undefined : sourceFile); let start = new Date().getTime(); @@ -370,16 +680,66 @@ namespace ts { function processRootFile(fileName: string, isDefaultLib: boolean) { processSourceFile(normalizePath(fileName), isDefaultLib); + } + + function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { + return a.fileName === b.fileName; + } + + function moduleNameIsEqualTo(a: LiteralExpression, b: LiteralExpression): boolean { + return a.text === b.text; + } + + function collectExternalModuleReferences(file: SourceFile): void { + if (file.imports) { + return; + } + + let imports: LiteralExpression[]; + for (let node of file.statements) { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportDeclaration: + let moduleNameExpr = getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { + break; + } + if (!(moduleNameExpr).text) { + break; + } + + (imports || (imports = [])).push(moduleNameExpr); + break; + case SyntaxKind.ModuleDeclaration: + if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + forEachChild((node).body, node => { + if (isExternalModuleImportEqualsDeclaration(node) && + getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) { + let moduleName = getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + + file.imports = imports || emptyArray; } function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { - let start: number; - let length: number; let diagnosticArgument: string[]; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; - } let diagnostic: DiagnosticMessage; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { @@ -411,8 +771,8 @@ namespace ts { } if (diagnostic) { - if (refFile) { - diagnostics.add(createFileDiagnostic(refFile, start, length, diagnostic, ...diagnosticArgument)); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument)); } else { diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); @@ -421,7 +781,7 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile { + function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result @@ -436,8 +796,8 @@ namespace ts { // We haven't looked for this file, do so now and cache result let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { - if (refFile) { - diagnostics.add(createFileDiagnostic(refFile, refStart, refLength, + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { @@ -450,12 +810,15 @@ namespace ts { // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); - + + let basePath = getDirectoryPath(fileName); if (!options.noResolve) { - let basePath = getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -473,8 +836,13 @@ namespace ts { if (file && host.useCaseSensitiveFileNames()) { let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(createFileDiagnostic(refFile, refStart, refLength, - Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + diagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -483,60 +851,33 @@ namespace ts { function processReferencedFiles(file: SourceFile, basePath: string) { forEach(file.referencedFiles, ref => { - let referencedFileName = isRootedDiskPath(ref.fileName) ? ref.fileName : combinePaths(basePath, ref.fileName); - processSourceFile(normalizePath(referencedFileName), /* isDefaultLib */ false, file, ref.pos, ref.end); + let referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } - + function processImportedModules(file: SourceFile, basePath: string) { - forEach(file.statements, node => { - if (node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration) { - let moduleNameExpr = getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === SyntaxKind.StringLiteral) { - let moduleNameText = (moduleNameExpr).text; - if (moduleNameText) { - let searchPath = basePath; - let searchName: string; - while (true) { - searchName = normalizePath(combinePaths(searchPath, moduleNameText)); - if (forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, moduleNameExpr))) { - break; - } - let parentPath = getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + let moduleNames = map(file.imports, name => name.text); + let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (let i = 0; i < file.imports.length; ++i) { + let resolution = resolutions[i]; + setResolvedModuleName(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + findModuleSourceFile(resolution, file.imports[i]); } } - else if (node.kind === SyntaxKind.ModuleDeclaration && (node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - forEachChild((node).body, node => { - if (isExternalModuleImportEqualsDeclaration(node) && - getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) { - - let nameLiteral = getExternalModuleImportEqualsDeclarationExpression(node); - let moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - let searchName = normalizePath(combinePaths(basePath, moduleName)); - forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral)); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName: string, nameLiteral: Expression) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); } } @@ -603,27 +944,31 @@ namespace ts { function verifyCompilerOptions() { if (options.isolatedModules) { if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + + if (options.outFile) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } @@ -634,18 +979,23 @@ namespace ts { } } + if (options.out && options.outFile) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } let languageVersion = options.target || ScriptTarget.ES3; + let outFile = options.outFile || options.out; let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (options.isolatedModules) { @@ -675,7 +1025,7 @@ namespace ts { if (options.outDir || // there is --outDir specified options.sourceRoot || // there is --sourceRoot specified (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory @@ -695,18 +1045,26 @@ namespace ts { } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + + if (options.outFile) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + + if (options.outDir) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index d52f96c912b..199e7e9b638 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -319,14 +319,21 @@ namespace ts { } /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) { let lineNumber = binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -401,6 +408,9 @@ namespace ts { case CharacterCodes.greaterThan: // Starts of conflict marker trivia return true; + case CharacterCodes.hash: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > CharacterCodes.maxAsciiCharacter; } @@ -461,6 +471,13 @@ namespace ts { } break; + case CharacterCodes.hash: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -528,13 +545,31 @@ namespace ts { return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + const shebangTriviaRegex = /^#!.*/; + + function isShebangTrivia(text: string, pos: number) { + // Shebangs check must only be done at the start of the file + Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + + function scanShebangTrivia(text: string, pos: number) { + let shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; let collecting = trailing || pos === 0; @@ -617,6 +652,13 @@ namespace ts { export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] { return getCommentRanges(text, pos, /*trailing*/ true); } + + /** Optionally, get the shebang */ + export function getShebang(text: string): string { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean { return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z || @@ -629,9 +671,8 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - - /* @internal */ - // Creates a scanner over a (possibly unspecified) range of a piece of text. + + // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant = LanguageVariant.Standard, @@ -1087,6 +1128,18 @@ namespace ts { return token = SyntaxKind.EndOfFileToken; } let ch = text.charCodeAt(pos); + + // Special handling for shebang + if (ch === CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = SyntaxKind.ShebangTrivia; + } + } + switch (ch) { case CharacterCodes.lineFeed: case CharacterCodes.carriageReturn: diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 228b9516de1..5b46324601b 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -30,8 +30,8 @@ namespace ts { declare var global: any; declare var __filename: string; declare var Buffer: { - new (str: string, encoding ?: string): any; - } + new (str: string, encoding?: string): any; + }; declare class Enumerator { public atEnd(): boolean; @@ -188,13 +188,13 @@ namespace ts { }; } function getNodeSystem(): System { - var _fs = require("fs"); - var _path = require("path"); - var _os = require('os'); + const _fs = require("fs"); + const _path = require("path"); + const _os = require("os"); - var platform: string = _os.platform(); + const platform: string = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName: string, encoding?: string): string { if (!_fs.existsSync(fileName)) { @@ -228,7 +228,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); @@ -271,10 +271,10 @@ namespace ts { newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write(s: string): void { - var buffer = new Buffer(s, 'utf8'); - var offset: number = 0; - var toWrite: number = buffer.length; - var written = 0; + const buffer = new Buffer(s, "utf8"); + let offset: number = 0; + let toWrite: number = buffer.length; + let written = 0; // 1 is a standard descriptor for stdout while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { offset += written; @@ -297,7 +297,7 @@ namespace ts { } callback(fileName); - }; + } }, resolvePath: function (path: string): string { return _path.resolve(path); @@ -334,7 +334,9 @@ namespace ts { if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { diff --git a/src/compiler/transform.ts b/src/compiler/transform.ts index 36a86881609..ed1e2bbf062 100644 --- a/src/compiler/transform.ts +++ b/src/compiler/transform.ts @@ -1,6 +1,6 @@ /// /// -const FORCE_TRANSFORMS = true; +const FORCE_TRANSFORMS = false; /* @internal */ namespace ts { diff --git a/src/compiler/transforms/es5.ts b/src/compiler/transforms/es5.ts index a0466421366..21e5dc434d4 100644 --- a/src/compiler/transforms/es5.ts +++ b/src/compiler/transforms/es5.ts @@ -526,7 +526,7 @@ namespace ts.transform { } function transformThisKeyword(node: LeftHandSideExpression): LeftHandSideExpression { - let container = getThisContainer(node, /*includeArrowFunctions*/ true, peekNode, /*offset*/ 0); + let container = getThisContainer(node, /*includeArrowFunctions*/ true); if (isArrowFunction(container)) { let thisName = factory.createIdentifier("_this"); return thisName; diff --git a/src/compiler/transforms/es6.ts b/src/compiler/transforms/es6.ts index 730089b9bb3..ee725760316 100644 --- a/src/compiler/transforms/es6.ts +++ b/src/compiler/transforms/es6.ts @@ -362,7 +362,7 @@ namespace ts.transform { let name = getDeclarationName(node); Debug.assert(isIdentifier(name)); - if (getCombinedNodeFlags(node, peekNode, 0) & NodeFlags.Export) { + if (getCombinedNodeFlags(node) & NodeFlags.Export) { let container = getContainingModuleName(); let propExpr = factory.createPropertyAccessExpression2(container, name); return propExpr; @@ -1319,8 +1319,17 @@ namespace ts.transform { /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function serializeTypeReferenceNode(node: TypeReferenceNode) { - let typeName = node.typeName; - let result = resolver.getTypeReferenceSerializationKind(node); + Debug.fail("parent pointer"); + let location: Node = node.parent; + while (isDeclaration(location) || isTypeNode(location)) { + location = location.parent; + } + + // Clone the type name and parent it to a location outside of the current declaration. + let typeName = cloneEntityName(node.typeName); + typeName.parent = location; + + let result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case TypeReferenceSerializationKind.Unknown: let tempVar = declareLocal(); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2ba989550ef..d5bfb62a0c8 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -3,7 +3,7 @@ namespace ts { export interface SourceFile { - fileWatcher: FileWatcher; + fileWatcher?: FileWatcher; } /** @@ -14,7 +14,7 @@ namespace ts { let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { - errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); + errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); return false; } @@ -49,7 +49,7 @@ namespace ts { } // TODO: Add codePage support for readFile? - let fileContents = ''; + let fileContents = ""; try { fileContents = sys.readFile(filePath); } @@ -159,6 +159,11 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return sys.exit(ExitStatus.Success); + } + if (commandLine.options.version) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); return sys.exit(ExitStatus.Success); @@ -245,7 +250,7 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } - function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { + function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { // Return existing SourceFile object if one is available if (cachedProgram) { let sourceFile = cachedProgram.getSourceFile(fileName); @@ -357,22 +362,23 @@ namespace ts { return { program, exitStatus }; function compileProgram(): ExitStatus { - // First get any syntactic errors. - let diagnostics = program.getSyntacticDiagnostics(); - reportDiagnostics(diagnostics); + let diagnostics: Diagnostic[]; + + // First get and report any syntactic errors. + diagnostics = program.getSyntacticDiagnostics(); // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. if (diagnostics.length === 0) { - let diagnostics = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics); + diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); if (diagnostics.length === 0) { - let diagnostics = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics); + diagnostics = program.getSemanticDiagnostics(); } } + reportDiagnostics(diagnostics); + // If the user doesn't want us to emit, then we're done at this point. if (compilerOptions.noEmit) { return diagnostics.length @@ -490,6 +496,70 @@ namespace ts { return Array(paddingLength + 1).join(" "); } } + + function writeConfigFile(options: CompilerOptions, fileNames: string[]) { + let currentDirectory = sys.getCurrentDirectory(); + let file = combinePaths(currentDirectory, 'tsconfig.json'); + if (sys.fileExists(file)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + let compilerOptions = extend(options, defaultInitCompilerOptions); + let configurations: any = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + + if (fileNames && fileNames.length) { + // only set the files property if we have at least one file + configurations.files = fileNames; + } + + sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + + return; + + function serializeCompilerOptions(options: CompilerOptions): Map { + let result: Map = {}; + let optionsNameMap = getOptionNameMap().optionNameMap; + + for (let name in options) { + if (hasProperty(options, name)) { + let value = options[name]; + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + let optionDefinition = optionsNameMap[name.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + // string, number or boolean + result[name] = value; + } + else { + // Enum + let typeMap = >optionDefinition.type; + for (let key in typeMap) { + if (hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name] = key; + } + } + } + } + break; + } + } + } + return result; + } + } declare var global: any, require: any; if (typeof global !== "undefined" && Object.prototype.toString.call(global.process) === '[object process]') { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 85477c64a7b..d6323e42d03 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9,6 +9,7 @@ namespace ts { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } export interface TextRange { @@ -17,6 +18,7 @@ namespace ts { } // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync export const enum SyntaxKind { Unknown, EndOfFileToken, @@ -24,6 +26,8 @@ namespace ts { MultiLineCommentTrivia, NewLineTrivia, WhitespaceTrivia, + // We detect and preserve #! on the first line + ShebangTrivia, // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. ConflictMarkerTrivia, @@ -625,6 +629,54 @@ namespace ts { Failed = 2, FailedAndReported = 3 } + + // @internal + export interface ParentNavigable { + /** Creates an object used to navigate parent nodes of this node. */ + createParentNavigator(): ParentNavigator; + } + + // @internal + export interface ParentNavigator extends ParentNavigable { + /** Gets the root node for the current node. */ + getRoot(): Node; + /** Gets the grandparent node for the current node. */ + getGrandparent(): Node; + /** Gets the parent node for the current node. */ + getParent(): Node; + /** Gets the current node. */ + getNode(): Node; + /** Gets the SyntaxKind of the current node. */ + getKind(): SyntaxKind; + /** Moves the navigator to the parent node of the current node. */ + moveToParent(): boolean; + /** Moves the navigator to the root node of the current node. */ + moveToRoot(): boolean; + } + + // @internal + export interface NodeStack extends ParentNavigable { + /** Gets the node at the bottom of the stack. */ + getRoot(): Node; + /** Gets the node two steps down from the top of the stack. */ + getGrandparent(): Node; + /** Gets the node one step down from the top of the stack. */ + getParent(): Node; + /** Gets the node at the top of the stack. */ + getNode(): Node; + /** Gets the SyntaxKind for the node at the top of the stack. */ + getKind(): SyntaxKind; + /** Traverses the stack from top to bottom until it finds a node that matches the supplied predicate. */ + findAncestorNode(match: (node: Node) => node is T): T; + /** Traverses the stack from top to bottom until it finds a node that matches the supplied predicate. */ + findAncestorNode(match: (node: Node) => boolean): Node; + /** Pushes a node onto the stack. */ + pushNode(node: Node): void; + /** Replaces the node at the top of the stack. */ + setNode(node: Node): void; + /** Pops the top node from the stack. */ + popNode(): void; + } // @factoryhidden("decorators", true) // @factoryhidden("modifiers", true) @@ -652,6 +704,7 @@ namespace ts { /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) /* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes) + /* @internal */ createParentNavigator(): ParentNavigator; } export interface NodeArray extends Array, TextRange { @@ -857,11 +910,10 @@ namespace ts { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ - // @ export interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -1791,6 +1843,10 @@ namespace ts { moduleName: string; referencedFiles: FileReference[]; languageVariant: LanguageVariant; + + // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) + /* @internal */ + renamedDependencies?: Map; /** * lib.d.ts should have a reference comment like @@ -1823,8 +1879,12 @@ namespace ts { // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. /* @internal */ lineMap: number[]; - /* @internal */ classifiableNames?: Map; + // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined + // It is used to resolve module names in the checker. + // Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead + /* @internal */ resolvedModules: Map; + /* @internal */ imports: LiteralExpression[]; } export interface ScriptReferenceHost { @@ -1833,7 +1893,7 @@ namespace ts { getCurrentDirectory(): string; } - export interface ParseConfigHost { + export interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } @@ -1851,6 +1911,12 @@ namespace ts { } export interface Program extends ScriptReferenceHost { + + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[] + /** * Get a list of files in the program */ @@ -1891,6 +1957,9 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + + // For testing purposes only. + /* @internal */ structureIsReused?: boolean; } export interface SourceMapSpan { @@ -1941,6 +2010,7 @@ namespace ts { /* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps } + /* @internal */ export interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; @@ -1982,6 +2052,7 @@ namespace ts { getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -2080,8 +2151,8 @@ namespace ts { export interface SymbolAccessiblityResult extends SymbolVisibilityResult { errorModuleName?: string; // If the symbol is not visible from module, module's name } - - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator * metadata */ /* @internal */ export enum TypeReferenceSerializationKind { @@ -2125,7 +2196,8 @@ namespace ts { getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; getBlockScopedVariableId(node: Identifier): number; getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind; + getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; + isOptionalParameter(node: ParameterDeclaration): boolean; } export const enum SymbolFlags { @@ -2319,7 +2391,9 @@ namespace ts { ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type /* @internal */ ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type - ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6 + /* @internal */ + ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type + ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6 /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -2331,7 +2405,9 @@ namespace ts { UnionOrIntersection = Union | Intersection, StructuredType = ObjectType | Union | Intersection, /* @internal */ - RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral + RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral, + /* @internal */ + PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType } // Properties common to all types @@ -2476,6 +2552,7 @@ namespace ts { /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; + instantiations?: Type[]; // Cache of instantiations created using this type mapper. context?: InferenceContext; // The inference context this mapper was created from. // Only inference mappers have this set (in createInferenceMapper). // The identity mapper and regular instantiation mappers do not need it. @@ -2532,7 +2609,12 @@ namespace ts { Error, Message, } - + + export const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2 + } + export interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -2540,6 +2622,7 @@ namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -2556,6 +2639,7 @@ namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -2563,6 +2647,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; @@ -2571,6 +2656,7 @@ namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; /* @internal */ experimentalTransforms?: boolean; /* @internal */ stripInternal?: boolean; @@ -2772,9 +2858,23 @@ namespace ts { byteOrderMark = 0xFEFF, tab = 0x09, // \t verticalTab = 0x0B, // \v + } + + export interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + // readFile function is used to read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' + // to determine location of bundled typings for node module + readFile(fileName: string): string; } + + export interface ResolvedModule { + resolvedFileName: string; + failedLookupLocations: string[]; + } + + export type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; - export interface CompilerHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; @@ -2783,6 +2883,15 @@ namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + + /* + * CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of + * module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler + * will appply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions). + * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just + * 'throw new Error("NotImplemented")' + */ + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } export interface TextSpan { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 32d7b2c611b..3fa30cddb18 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -80,6 +80,41 @@ namespace ts { return node.end - node.pos; } + export function arrayIsEqualTo(arr1: T[], arr2: T[], comparer?: (a: T, b: T) => boolean): boolean { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + + if (arr1.length !== arr2.length) { + return false; + } + + for (let i = 0; i < arr1.length; ++i) { + let equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + + return true; + } + + export function hasResolvedModuleName(sourceFile: SourceFile, moduleNameText: string): boolean { + return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText); + } + + export function getResolvedModuleFileName(sourceFile: SourceFile, moduleNameText: string): string { + return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + + export function setResolvedModuleName(sourceFile: SourceFile, moduleNameText: string, resolvedFileName: string): void { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + + sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + } + // Returns true if this node contains a parse error anywhere underneath it. export function containsParseError(node: Node): boolean { aggregateChildData(node); @@ -205,7 +240,7 @@ namespace ts { // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores export function makeIdentifierFromModuleName(moduleName: string): string { - return getBaseFileName(moduleName).replace(/\W/g, "_"); + return getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } export function isBlockOrCatchScoped(declaration: Declaration) { @@ -215,38 +250,10 @@ namespace ts { // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. - export function getEnclosingBlockScopeContainer(node: Node): Node; - - /** - * Gets the nearest enclosing block scope container that has the provided node - * as a descendant, that is not the provided node. - * @param node The starting node - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - */ - export function getEnclosingBlockScopeContainer(node: Node, getAncestorOrSelf: (offset: number) => Node, offset: number): Node; - - /** - * Gets the nearest enclosing block scope container that has the provided node - * as a descendant, that is not the provided node. - * @param node The starting node - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - * @remarks - * The emitter tracks the parent of the current node as it descends into the source file, - * so that we can properly emit synthesized nodes that may not have parent pointers. - * We can call `getAncestorOrSelf` with an offset that specifies how far back in the node's - * ancestry to retrieve a parent, grandparent, etc. An offset of zero (0) refers to the - * current node on the top of the node stack, an offset of one (1) refers to its parent, an - * offset of two (2) refers to the grandparent, and so on. - */ - export function getEnclosingBlockScopeContainer(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): Node { - let current = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - while (current) { + export function getEnclosingBlockScopeContainer(navigable: ParentNavigable): Node { + let nav = navigable.createParentNavigator(); + while (nav.moveToParent()) { + let current = nav.getNode(); if (isFunctionLike(current)) { return current; } @@ -262,12 +269,10 @@ namespace ts { case SyntaxKind.Block: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block - if (!isFunctionLike(getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : current.parent)) { + if (!isFunctionLike(nav.getParent())) { return current; } } - - current = getAncestorOrSelf ? getAncestorOrSelf(++offset) : current.parent; } } @@ -362,56 +367,22 @@ namespace ts { return node.kind === SyntaxKind.EnumDeclaration && isConst(node); } - /** - * Returns the node flags for this node and all relevant parent nodes. - */ - export function getCombinedNodeFlags(node: Node): NodeFlags; - - /** - * Returns the node flags for this node and all relevant parent nodes. - * @param node The starting node - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - */ - export function getCombinedNodeFlags(node: Node, getAncestorOrSelf: (offset: number) => Node, offset: number): NodeFlags; - - /** - * Returns the node flags for this node and all relevant parent nodes. - * @param node The starting node - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - * @remarks - * This is done so that nodes like variable declarations and binding elements can return - * a view of their flags that includes the modifiers from their container. i.e. flags like - * export/declare aren't stored on the variable declaration directly, but on the containing - * variable statement (if it has one). Similarly, flags for let/const are store on the - * variable declaration list. By calling this function, all those flags are combined so - * that the client can treat the node as if it actually had those flags. - * - * The emitter tracks the parent of the current node as it descends into the source file, - * so that we can properly emit synthesized nodes that may not have parent pointers. - * We can call `getAncestorOrSelf` with an offset that specifies how far back in the node's - * ancestry to retrieve a parent, grandparent, etc. An offset of zero (0) refers to the - * current node on the top of the node stack, an offset of one (1) refers to its parent, an - * offset of two (2) refers to the grandparent, and so on. - */ - export function getCombinedNodeFlags(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): NodeFlags { + /** Returns the node flags for this node and all relevant parent nodes. */ + export function getCombinedNodeFlags(navigable: ParentNavigable): NodeFlags { + let nav = navigable.createParentNavigator(); + let node = nav.getNode(); while (node && (node.kind === SyntaxKind.BindingElement || isBindingPattern(node))) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + node = nav.moveToParent() ? nav.getNode() : undefined; } let flags = node.flags; if (node.kind === SyntaxKind.VariableDeclaration) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + node = nav.moveToParent() ? nav.getNode() : undefined; } if (node && node.kind === SyntaxKind.VariableDeclarationList) { flags |= node.flags; - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + node = nav.moveToParent() ? nav.getNode() : undefined; } if (node && node.kind === SyntaxKind.VariableStatement) { @@ -421,12 +392,12 @@ namespace ts { return flags; } - export function isConst(node: Node): boolean { - return !!(getCombinedNodeFlags(node) & NodeFlags.Const); + export function isConst(navigable: ParentNavigable): boolean { + return !!(getCombinedNodeFlags(navigable) & NodeFlags.Const); } - export function isLet(node: Node): boolean { - return !!(getCombinedNodeFlags(node) & NodeFlags.Let); + export function isLet(navigable: ParentNavigable): boolean { + return !!(getCombinedNodeFlags(navigable) & NodeFlags.Let); } export function isPrologueDirective(node: Node): boolean { @@ -453,24 +424,15 @@ namespace ts { } export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { - // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) { - // e.g. (/** blah */ a, /** blah */ b); - - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return concatenate( - getTrailingCommentRanges(sourceFileOfNode.text, node.pos), - getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) { - return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? + concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), + getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return filter(commentRanges, isJsDocComment); function isJsDocComment(comment: CommentRange) { // True if the comment starts with '/**' but not if it is '/**/' @@ -687,6 +649,20 @@ namespace ts { return false; } + export function introducesArgumentsExoticObject(node: Node) { + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + return true; + } + return false; + } + export function isFunctionBlock(node: Node) { return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent); } @@ -695,43 +671,41 @@ namespace ts { return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression; } - export function getContainingFunction(node: Node): FunctionLikeDeclaration; - export function getContainingFunction(node: Node, getAncestorOrSelf: (offset: number) => Node, offset: number): FunctionLikeDeclaration; - export function getContainingFunction(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): FunctionLikeDeclaration { - while (true) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - if (!node || isFunctionLike(node)) { + export function getContainingFunction(navigable: ParentNavigable): FunctionLikeDeclaration { + let nav = navigable.createParentNavigator(); + while (nav.moveToParent()) { + let node = nav.getNode(); + if (isFunctionLike(node)) { return node; } } + + return undefined; } - export function getContainingClass(node: Node): ClassLikeDeclaration; - export function getContainingClass(node: Node, getAncestorOrSelf: (offset: number) => Node, offset: number): ClassLikeDeclaration; - export function getContainingClass(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): ClassLikeDeclaration { - while (true) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - if (!node || isClassLike(node)) { + export function getContainingClass(navigable: ParentNavigable): ClassLikeDeclaration { + let nav = navigable.createParentNavigator(); + while (nav.moveToParent()) { + let node = nav.getNode(); + if (isClassLike(node)) { return node; } } + + return undefined; } - export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - export function getThisContainer(node: Node, includeArrowFunctions: boolean, getAncestorOrSelf: (offset: number) => Node, offset: number): Node; - export function getThisContainer(node: Node, includeArrowFunctions: boolean, getAncestorOrSelf?: (offset: number) => Node, offset?: number): Node { - while (true) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - if (!node) { - return undefined; - } + export function getThisContainer(navigable: ParentNavigable, includeArrowFunctions: boolean): Node { + let nav = navigable.createParentNavigator(); + while (nav.moveToParent()) { + let node = nav.getNode(); switch (node.kind) { case SyntaxKind.ComputedPropertyName: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container // so that we can error on it. - if (isClassLike(getAncestorOrSelf ? getAncestorOrSelf(offset + 2) : node.parent.parent)) { + if (isClassLike(nav.getGrandparent())) { return node; } // If this is a computed property, then the parent should not @@ -739,20 +713,20 @@ namespace ts { // in an object literal, like a method or accessor. But in order for // such a parent to be a this container, the reference must be in // the *body* of the container. - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + nav.moveToParent(); break; case SyntaxKind.Decorator: // Decorators are always applied outside of the body of a class or method. - if (isParameter(getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent) - && isClassElement(getAncestorOrSelf ? getAncestorOrSelf(offset + 2) : node.parent.parent)) { + if (nav.getParent().kind === SyntaxKind.Parameter && isClassElement(nav.getGrandparent())) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. - node = getAncestorOrSelf ? getAncestorOrSelf(offset += 2) : node.parent.parent; + nav.moveToParent(); + nav.moveToParent(); } - else if (isClassElement(getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent)) { + else if (isClassElement(nav.getParent())) { // If the decorator's parent is a class element, we resolve the 'this' container // from the parent class declaration. - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + nav.moveToParent(); } break; case SyntaxKind.ArrowFunction: @@ -777,19 +751,17 @@ namespace ts { } } - export function getSuperContainer(node: Node, includeFunctions: boolean): Node; - export function getSuperContainer(node: Node, includeFunctions: boolean, getAncestorOrSelf: (offset: number) => Node, offset: number): Node; - export function getSuperContainer(node: Node, includeFunctions: boolean, getAncestorOrSelf?: (offset: number) => Node, offset?: number): Node { - while (true) { - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - if (!node) return node; + export function getSuperContainer(navigable: ParentNavigable, includeFunctions: boolean): Node { + let nav = navigable.createParentNavigator(); + while (nav.moveToParent()) { + let node = nav.getNode(); switch (node.kind) { case SyntaxKind.ComputedPropertyName: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container // so that we can error on it. - if (isClassLike(getAncestorOrSelf ? getAncestorOrSelf(offset + 2) : node.parent.parent)) { + if (isClassLike(nav.getGrandparent())) { return node; } // If this is a computed property, then the parent should not @@ -797,20 +769,20 @@ namespace ts { // in an object literal, like a method or accessor. But in order for // such a parent to be a super container, the reference must be in // the *body* of the container. - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + nav.moveToParent(); break; case SyntaxKind.Decorator: // Decorators are always applied outside of the body of a class or method. - if (isParameter(getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent) - && isClassElement(getAncestorOrSelf ? getAncestorOrSelf(offset + 2) : node.parent.parent)) { + if (nav.getParent().kind === SyntaxKind.Parameter && isClassElement(nav.getGrandparent())) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. - node = getAncestorOrSelf ? getAncestorOrSelf(offset += 2) : node.parent.parent; + nav.moveToParent(); + nav.moveToParent(); } - else if (isClassElement(getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent)) { + else if (isClassElement(nav.getParent())) { // If the decorator's parent is a class element, we resolve the 'this' container // from the parent class declaration. - node = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; + nav.moveToParent(); } break; case SyntaxKind.FunctionDeclaration: @@ -865,7 +837,9 @@ namespace ts { return (node).expression; } - export function nodeCanBeDecorated(node: Node): boolean { + export function nodeCanBeDecorated(navigable: ParentNavigable): boolean { + let nav = navigable.createParentNavigator(); + let node = nav.getNode(); switch (node.kind) { case SyntaxKind.ClassDeclaration: // classes are valid targets @@ -873,17 +847,17 @@ namespace ts { case SyntaxKind.PropertyDeclaration: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === SyntaxKind.ClassDeclaration; + return nav.getParent().kind === SyntaxKind.ClassDeclaration; case SyntaxKind.Parameter: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return (node.parent).body && node.parent.parent.kind === SyntaxKind.ClassDeclaration; + return (nav.getParent()).body && nav.getGrandparent().kind === SyntaxKind.ClassDeclaration; case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.MethodDeclaration: // if this method has a body and its parent is a class declaration, this is a valid target. - return (node).body && node.parent.kind === SyntaxKind.ClassDeclaration; + return (node).body && nav.getParent().kind === SyntaxKind.ClassDeclaration; } return false; @@ -942,141 +916,151 @@ namespace ts { return nodeIsDecorated(node) || childIsDecorated(node); } - /** - * Returns whether the node is part of an expression. - * @param node The node to test - */ - export function isPartOfExpression(node: Node): boolean; - - /** - * Returns whether the node is part of an expression. - * @param node The node to test - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - */ - export function isPartOfExpression(node: Node, getAncestorOrSelf: (offset: number) => Node, offset: number): boolean; - - /** - * Returns whether the node is part of an expression. - * @param node The node to test - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - * @remarks - * The emitter tracks the parent of the current node as it descends into the source file, - * so that we can properly emit synthesized nodes that may not have parent pointers. - * We can call `getAncestorOrSelf` with an offset that specifies how far back in the node's - * ancestry to retrieve a parent, grandparent, etc. An offset of zero (0) refers to the - * current node on the top of the node stack, an offset of one (1) refers to its parent, an - * offset of two (2) refers to the grandparent, and so on. - */ - export function isPartOfExpression(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): boolean { - let parent: Node; - switch (node.kind) { - case SyntaxKind.ThisKeyword: - case SyntaxKind.SuperKeyword: - case SyntaxKind.NullKeyword: - case SyntaxKind.TrueKeyword: - case SyntaxKind.FalseKeyword: - case SyntaxKind.RegularExpressionLiteral: - case SyntaxKind.ArrayLiteralExpression: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ElementAccessExpression: - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.AsExpression: - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.ParenthesizedExpression: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ClassExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.VoidExpression: - case SyntaxKind.DeleteExpression: - case SyntaxKind.TypeOfExpression: - case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixUnaryExpression: - case SyntaxKind.BinaryExpression: - case SyntaxKind.ConditionalExpression: - case SyntaxKind.SpreadElementExpression: - case SyntaxKind.TemplateExpression: - case SyntaxKind.NoSubstitutionTemplateLiteral: - case SyntaxKind.OmittedExpression: - case SyntaxKind.JsxElement: - case SyntaxKind.JsxSelfClosingElement: - case SyntaxKind.YieldExpression: - return true; - case SyntaxKind.QualifiedName: - parent = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - while (parent.kind === SyntaxKind.QualifiedName) { - node = parent; - parent = getAncestorOrSelf ? getAncestorOrSelf(++offset) : node.parent; - } - return parent.kind === SyntaxKind.TypeQuery; - - case SyntaxKind.Identifier: - parent = getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent; - if (parent.kind === SyntaxKind.TypeQuery) { + /** Returns whether the node is part of an expression. */ + export function isPartOfExpression(navigable: ParentNavigable): boolean { + let nav = navigable.createParentNavigator(); + while (true) { + let node = nav.getNode(); + switch (node.kind) { + case SyntaxKind.ThisKeyword: + case SyntaxKind.SuperKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.TrueKeyword: + case SyntaxKind.FalseKeyword: + case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ClassExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.VoidExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.BinaryExpression: + case SyntaxKind.ConditionalExpression: + case SyntaxKind.SpreadElementExpression: + case SyntaxKind.TemplateExpression: + case SyntaxKind.NoSubstitutionTemplateLiteral: + case SyntaxKind.OmittedExpression: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.YieldExpression: return true; - } - // fall through - case SyntaxKind.NumericLiteral: - case SyntaxKind.StringLiteral: - parent = getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent; - switch (parent.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.EnumMember: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.BindingElement: - return (parent).initializer === node; - case SyntaxKind.ExpressionStatement: - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ReturnStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.CaseClause: - case SyntaxKind.ThrowStatement: - case SyntaxKind.SwitchStatement: - return (parent).expression === node; - case SyntaxKind.ForStatement: - let forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forStatement.condition === node || - forStatement.incrementor === node; - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - let forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forInStatement.expression === node; - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.AsExpression: - return node === (parent).expression; - case SyntaxKind.TemplateSpan: - return node === (parent).expression; - case SyntaxKind.ComputedPropertyName: - return node === (parent).expression; - case SyntaxKind.Decorator: - return true; - case SyntaxKind.ExpressionWithTypeArguments: - return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent, getAncestorOrSelf, offset + 1); - default: - if (isPartOfExpression(parent, getAncestorOrSelf, offset)) { - return true; + case SyntaxKind.QualifiedName: + while (nav.moveToParent()) { + if (nav.getKind() !== SyntaxKind.QualifiedName) { + break; } - } + } + + return nav.getKind() === SyntaxKind.TypeQuery; + + case SyntaxKind.Identifier: + if (nav.getParent().kind === SyntaxKind.TypeQuery) { + return true; + } + + // fall through + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + nav.moveToParent(); + + let parent = nav.getNode(); + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.EnumMember: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.BindingElement: + return (parent).initializer === node; + case SyntaxKind.ExpressionStatement: + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ReturnStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.CaseClause: + case SyntaxKind.ThrowStatement: + case SyntaxKind.SwitchStatement: + return (parent).expression === node; + case SyntaxKind.ForStatement: + let forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forStatement.condition === node || + forStatement.incrementor === node; + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + let forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forInStatement.expression === node; + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return node === (parent).expression; + case SyntaxKind.TemplateSpan: + return node === (parent).expression; + case SyntaxKind.ComputedPropertyName: + return node === (parent).expression; + case SyntaxKind.Decorator: + case SyntaxKind.JsxExpression: + return true; + case SyntaxKind.ExpressionWithTypeArguments: + return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(nav); + default: + continue; + } + } + return false; } - return false; } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + export function comparePrecedenceToBinaryPlus(expression: Expression): Comparison { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case SyntaxKind.BinaryExpression: + switch ((expression).operatorToken.kind) { + case SyntaxKind.AsteriskToken: + case SyntaxKind.SlashToken: + case SyntaxKind.PercentToken: + return Comparison.GreaterThan; + case SyntaxKind.PlusToken: + case SyntaxKind.MinusToken: + return Comparison.EqualTo; + default: + return Comparison.LessThan; + } + case SyntaxKind.YieldExpression: + case SyntaxKind.ConditionalExpression: + return Comparison.LessThan; + default: + return Comparison.GreaterThan; + } + } + export function getExpressionPrecedence(expr: Expression) { return getOperatorPrecedence(expr.kind, getOperator(expr), isNewExpression(expr) && !expr.arguments) } @@ -1259,15 +1243,13 @@ namespace ts { if (node) { switch (node.kind) { case SyntaxKind.Parameter: - return (node).questionToken !== undefined; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return (node).questionToken !== undefined; case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.PropertyAssignment: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return (node).questionToken !== undefined; + return (node).questionToken !== undefined; } } @@ -1700,6 +1682,22 @@ namespace ts { return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; } + export function cloneEntityName(node: EntityName): EntityName { + if (node.kind === SyntaxKind.Identifier) { + let clone = createNode(SyntaxKind.Identifier); + clone.text = (node).text; + return clone; + } + else { + let clone = createNode(SyntaxKind.QualifiedName); + clone.left = cloneEntityName((node).left); + clone.left.parent = clone; + clone.right = cloneEntityName((node).right); + clone.right.parent = clone; + return clone; + } + } + export function nodeIsSynthesized(node: Node): boolean { return node && node.pos === -1; } @@ -1975,7 +1973,7 @@ namespace ts { export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js"); @@ -2138,7 +2136,7 @@ namespace ts { function writeTrimmedCurrentLine(pos: number, nextLineStart: number) { let end = Math.min(comment.end, nextLineStart - 1); - let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -2225,25 +2223,12 @@ namespace ts { /** * Tests whether the node is an ExpressionWithTypeArguments node that is part of the `extends` * clause of a class. - * @param node The node to test - * @param getAncestorOrSelf A callback used to get the ancestor of the starting node, used - * only when traversing the ancestors of the current node in the emitter. - * @param offset The offset in the node stack used to get the ancestor of the current node - * from the emitter's node stack. - * @remarks - * The emitter tracks the parent of the current node as it descends into the source file, - * so that we can properly emit synthesized nodes that may not have parent pointers. - * We can call `getAncestorOrSelf` with an offset that specifies how far back in the node's - * ancestry to retrieve a parent, grandparent, etc. An offset of zero (0) refers to the - * current node on the top of the node stack, an offset of one (1) refers to its parent, an - * offset of two (2) refers to the grandparent, and so on. */ - export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node, getAncestorOrSelf?: (offset: number) => Node, offset?: number): boolean { - if (node.kind === SyntaxKind.ExpressionWithTypeArguments) { - let parent = getAncestorOrSelf ? getAncestorOrSelf(offset + 1) : node.parent; - if ((parent).token === SyntaxKind.ExtendsKeyword) { - let grandparent = getAncestorOrSelf ? getAncestorOrSelf(offset + 2) : parent.parent; - return isClassLike(grandparent); + export function isExpressionWithTypeArgumentsInClassExtendsClause(navigable: ParentNavigable): boolean { + let nav = navigable.createParentNavigator(); + if (nav.getKind() === SyntaxKind.ExpressionWithTypeArguments) { + if ((nav.getParent()).token === SyntaxKind.ExtendsKeyword) { + return isClassLike(nav.getGrandparent()); } } return false; diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index b1d43302372..87e22e08cfa 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -1,6 +1,6 @@ -/// -/// -/// +/// +/// +/// const enum CompilerTestType { Conformance, @@ -9,7 +9,7 @@ const enum CompilerTestType { } class CompilerBaselineRunner extends RunnerBase { - private basePath = 'tests/cases'; + private basePath = "tests/cases"; private testSuiteName: string; private errors: boolean; private emit: boolean; @@ -25,21 +25,21 @@ class CompilerBaselineRunner extends RunnerBase { this.decl = true; this.output = true; if (testType === CompilerTestType.Conformance) { - this.testSuiteName = 'conformance'; + this.testSuiteName = "conformance"; } else if (testType === CompilerTestType.Regressions) { - this.testSuiteName = 'compiler'; + this.testSuiteName = "compiler"; } else if (testType === CompilerTestType.Test262) { - this.testSuiteName = 'test262'; + this.testSuiteName = "test262"; } else { - this.testSuiteName = 'compiler'; // default to this for historical reasons + this.testSuiteName = "compiler"; // default to this for historical reasons } - this.basePath += '/' + this.testSuiteName; + this.basePath += "/" + this.testSuiteName; } public checkTestCodeOutput(fileName: string) { - describe('compiler tests for ' + fileName, () => { + describe("compiler tests for " + fileName, () => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Everything declared here should be cleared out in the "after" callback. let justName: string; @@ -64,14 +64,14 @@ class CompilerBaselineRunner extends RunnerBase { let createNewInstance = false; before(() => { - justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path. + justName = fileName.replace(/^.*[\\\/]/, ""); // strips the fileName from the path. content = Harness.IO.readFile(fileName); testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName); units = testCaseContent.testUnitData; tcSettings = testCaseContent.settings; createNewInstance = false; lastUnit = units[units.length - 1]; - rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/'; + rootDir = lastUnit.originalFilePath.indexOf("conformance") === -1 ? "tests/cases/compiler/" : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf("/")) + "/"; harnessCompiler = Harness.Compiler.getCompiler(); // We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test) // If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references, @@ -106,7 +106,7 @@ class CompilerBaselineRunner extends RunnerBase { eventually to remove this limitation. */ for (let i = 0; i < tcSettings.length; ++i) { // noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings - if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === 'target')) { + if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === "target")) { harnessCompiler = Harness.Compiler.getCompiler(); harnessCompiler.setCompilerSettings(tcSettings); createNewInstance = true; @@ -148,9 +148,9 @@ class CompilerBaselineRunner extends RunnerBase { } // check errors - it('Correct errors for ' + fileName, () => { + it("Correct errors for " + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.tsx?$/, '.errors.txt'), (): string => { + Harness.Baseline.runBaseline("Correct errors for " + fileName, justName.replace(/\.tsx?$/, ".errors.txt"), (): string => { if (result.errors.length === 0) return null; return getErrorBaseline(toBeCompiled, otherFiles, result); }); @@ -158,12 +158,12 @@ class CompilerBaselineRunner extends RunnerBase { }); // Source maps? - it('Correct sourcemap content for ' + fileName, () => { + it("Correct sourcemap content for " + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => { + Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { let record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { - // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. + // Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required. return null; } return record; @@ -171,35 +171,35 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct JS output for ' + fileName, () => { - if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) { + it("Correct JS output for " + fileName, () => { + if (!ts.fileExtensionIs(lastUnit.name, ".d.ts") && this.emit) { if (result.files.length === 0 && result.errors.length === 0) { - throw new Error('Expected at least one js file to be emitted or at least one error to be created.'); + throw new Error("Expected at least one js file to be emitted or at least one error to be created."); } // check js output - Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => { - let tsCode = ''; + Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => { + let tsCode = ""; let tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { - tsCode += '//// [' + fileName + '] ////\r\n\r\n'; + tsCode += "//// [" + fileName + "] ////\r\n\r\n"; } for (let i = 0; i < tsSources.length; i++) { - tsCode += '//// [' + Harness.Path.getFileName(tsSources[i].unitName) + ']\r\n'; - tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? '\r\n' : ''); + tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n"; + tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : ""); } - let jsCode = ''; + let jsCode = ""; for (let i = 0; i < result.files.length; i++) { - jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n'; + jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n"; jsCode += getByteOrderMarkText(result.files[i]); jsCode += result.files[i].code; } if (result.declFilesCode.length > 0) { - jsCode += '\r\n\r\n'; + jsCode += "\r\n\r\n"; for (let i = 0; i < result.declFilesCode.length; i++) { - jsCode += '//// [' + Harness.Path.getFileName(result.declFilesCode[i].fileName) + ']\r\n'; + jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n"; jsCode += getByteOrderMarkText(result.declFilesCode[i]); jsCode += result.declFilesCode[i].code; } @@ -210,13 +210,13 @@ class CompilerBaselineRunner extends RunnerBase { }, options); if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { - jsCode += '\r\n\r\n//// [DtsFileErrors]\r\n'; - jsCode += '\r\n\r\n'; + jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; + jsCode += "\r\n\r\n"; jsCode += getErrorBaseline(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles, declFileCompilationResult.declResult); } if (jsCode.length > 0) { - return tsCode + '\r\n\r\n' + jsCode; + return tsCode + "\r\n\r\n" + jsCode; } else { return null; } @@ -224,28 +224,28 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct Sourcemap output for ' + fileName, () => { + it("Correct Sourcemap output for " + fileName, () => { if (options.inlineSourceMap) { if (result.sourceMaps.length > 0) { - throw new Error('No sourcemap files should be generated if inlineSourceMaps was set.'); + throw new Error("No sourcemap files should be generated if inlineSourceMaps was set."); } return null; } else if (options.sourceMap) { if (result.sourceMaps.length !== result.files.length) { - throw new Error('Number of sourcemap files should be same as js files.'); + throw new Error("Number of sourcemap files should be same as js files."); } - Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.tsx?/, '.js.map'), () => { + Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. return null; } - let sourceMapCode = ''; + let sourceMapCode = ""; for (let i = 0; i < result.sourceMaps.length; i++) { - sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n'; + sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n"; sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); sourceMapCode += result.sourceMaps[i].code; } @@ -255,7 +255,7 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct type/symbol baselines for ' + fileName, () => { + it("Correct type/symbol baselines for " + fileName, () => { if (fileName.indexOf("APISample") >= 0) { return; } @@ -317,15 +317,15 @@ class CompilerBaselineRunner extends RunnerBase { let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); let pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine); - let fullExtension = isSymbolBaseLine ? '.symbols' : '.types'; - let pullExtension = isSymbolBaseLine ? '.symbols.pull' : '.types.pull'; + let fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; + let pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); + Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline("Correct pull information for " + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); } else { - Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline("Correct information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); } } @@ -334,7 +334,7 @@ class CompilerBaselineRunner extends RunnerBase { let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; allFiles.forEach(file => { - let codeLines = file.content.split('\n'); + let codeLines = file.content.split("\n"); typeWriterResults[file.unitName].forEach(result => { if (isSymbolBaseline && !result.symbol) { return; @@ -354,30 +354,30 @@ class CompilerBaselineRunner extends RunnerBase { typeMap[file.unitName][result.line] = typeInfo; }); - typeLines.push('=== ' + file.unitName + ' ===\r\n'); + typeLines.push("=== " + file.unitName + " ===\r\n"); for (let i = 0; i < codeLines.length; i++) { let currentCodeLine = codeLines[i]; - typeLines.push(currentCodeLine + '\r\n'); + typeLines.push(currentCodeLine + "\r\n"); if (typeMap[file.unitName]) { let typeInfo = typeMap[file.unitName][i]; if (typeInfo) { typeInfo.forEach(ty => { - typeLines.push('>' + ty + '\r\n'); + typeLines.push(">" + ty + "\r\n"); }); - if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === '')) { + if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { } else { - typeLines.push('\r\n'); + typeLines.push("\r\n"); } } } else { - typeLines.push('No type information for this code.'); + typeLines.push("No type information for this code."); } } }); - return typeLines.join(''); + return typeLines.join(""); } } }); @@ -385,7 +385,7 @@ class CompilerBaselineRunner extends RunnerBase { } public initializeTests() { - describe(this.testSuiteName + ' tests', () => { + describe(this.testSuiteName + " tests", () => { describe("Setup compiler for compiler baselines", () => { let harnessCompiler = Harness.Compiler.getCompiler(); this.parseOptions(); @@ -416,23 +416,23 @@ class CompilerBaselineRunner extends RunnerBase { this.decl = false; this.output = false; - let opts = this.options.split(','); + let opts = this.options.split(","); for (let i = 0; i < opts.length; i++) { switch (opts[i]) { - case 'error': + case "error": this.errors = true; break; - case 'emit': + case "emit": this.emit = true; break; - case 'decl': + case "decl": this.decl = true; break; - case 'output': + case "output": this.output = true; break; default: - throw new Error('unsupported flag'); + throw new Error("unsupported flag"); } } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 272f4c1c1dd..5bfac3d9bb5 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -13,11 +13,11 @@ // limitations under the License. // -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// module FourSlash { ts.disableIncrementalParsing = false; @@ -100,12 +100,12 @@ module FourSlash { } let entityMap: ts.Map = { - '&': '&', - '"': '"', - "'": ''', - '/': '/', - '<': '<', - '>': '>' + "&": "&", + "\"": """, + "'": "'", + "/": "/", + "<": "<", + ">": ">" }; export function escapeXmlAttributeValue(s: string) { @@ -116,25 +116,27 @@ module FourSlash { // To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data let metadataOptionNames = { - baselineFile: 'BaselineFile', - declaration: 'declaration', - emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project - fileName: 'Filename', - mapRoot: 'mapRoot', - module: 'module', - out: 'out', - outDir: 'outDir', - sourceMap: 'sourceMap', - sourceRoot: 'sourceRoot', - allowNonTsExtensions: 'allowNonTsExtensions', - resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file + baselineFile: "BaselineFile", + declaration: "declaration", + emitThisFile: "emitThisFile", // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project + fileName: "Filename", + mapRoot: "mapRoot", + module: "module", + out: "out", + outFile: "outFile", + outDir: "outDir", + sourceMap: "sourceMap", + sourceRoot: "sourceRoot", + allowNonTsExtensions: "allowNonTsExtensions", + resolveReference: "ResolveReference", // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file + jsx: "jsx", }; // List of allowed metadata names let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, - metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out, - metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]; + metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,metadataOptionNames.outFile, + metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot, metadataOptionNames.jsx]; function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; @@ -169,6 +171,9 @@ module FourSlash { case metadataOptionNames.out: settings.out = globalOptions[prop]; break; + case metadataOptionNames.outFile: + settings.outFile = globalOptions[prop]; + break; case metadataOptionNames.outDir: settings.outDir = globalOptions[prop]; break; @@ -178,6 +183,20 @@ module FourSlash { case metadataOptionNames.sourceRoot: settings.sourceRoot = globalOptions[prop]; break; + case metadataOptionNames.jsx: + switch (globalOptions[prop].toLowerCase()) { + case "react": + settings.jsx = ts.JsxEmit.React; + break; + case "preserve": + settings.jsx = ts.JsxEmit.Preserve; + break; + default: + ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None"); + settings.jsx = ts.JsxEmit.None; + break; + } + break; } } } @@ -285,7 +304,9 @@ module FourSlash { case FourSlashTestType.Native: return new Harness.LanguageService.NativeLanugageServiceAdapter(cancellationToken, compilationOptions); case FourSlashTestType.Shims: - return new Harness.LanguageService.ShimLanugageServiceAdapter(cancellationToken, compilationOptions); + return new Harness.LanguageService.ShimLanugageServiceAdapter(/*preprocessToResolve*/ false, cancellationToken, compilationOptions); + case FourSlashTestType.ShimsWithPreprocess: + return new Harness.LanguageService.ShimLanugageServiceAdapter(/*preprocessToResolve*/ true, cancellationToken, compilationOptions); case FourSlashTestType.Server: return new Harness.LanguageService.ServerLanugageServiceAdapter(cancellationToken, compilationOptions); default: @@ -326,7 +347,7 @@ module FourSlash { // Add triple reference files into language-service host ts.forEach(referencedFiles, referenceFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path - let referenceFilePath = this.basePath + '/' + referenceFile.fileName; + let referenceFilePath = this.basePath + "/" + referenceFile.fileName; this.addMatchedInputFile(referenceFilePath); }); @@ -334,7 +355,7 @@ module FourSlash { ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison - let importedFilePath = this.basePath + '/' + importedFile.fileName + ".ts"; + let importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts"; this.addMatchedInputFile(importedFilePath); }); @@ -356,7 +377,7 @@ module FourSlash { this.formatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: Harness.IO.newLine(), ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -364,14 +385,15 @@ module FourSlash { InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }; this.testData.files.forEach(file => { - let fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1); + let fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1); let fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); - this.scenarioActions.push(''); + this.scenarioActions.push(""); }); // Open the first file by default @@ -384,7 +406,7 @@ module FourSlash { } // Entry points from fourslash.ts - public goToMarker(name = '') { + public goToMarker(name = "") { let marker = this.getMarkerByName(name); if (this.activeFile.fileName !== marker.fileName) { this.openFile(marker.fileName); @@ -392,7 +414,7 @@ module FourSlash { let content = this.getFileContent(marker.fileName); if (marker.position === -1 || marker.position > content.length) { - throw new Error('Marker "' + name + '" has been invalidated by unrecoverable edits to the file.'); + throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`); } this.lastKnownMarker = name; this.goToPosition(marker.position); @@ -410,9 +432,9 @@ module FourSlash { this.currentCaretPosition += count; this.currentCaretPosition = Math.min(this.currentCaretPosition, this.getFileContent(this.activeFile.fileName).length); if (count > 0) { - this.scenarioActions.push(''); + this.scenarioActions.push(``); } else { - this.scenarioActions.push(''); + this.scenarioActions.push(``); } } @@ -423,8 +445,8 @@ module FourSlash { let fileToOpen: FourSlashFile = this.findFile(indexOrName); fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName); this.activeFile = fileToOpen; - let fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1); - this.scenarioActions.push(''); + let fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), "").substr(1); + this.scenarioActions.push(``); // Let the host know that this file is now open this.languageServiceAdapterHost.openFile(fileToOpen.fileName); @@ -439,7 +461,7 @@ module FourSlash { let exists = this.anyErrorInRange(predicate, startMarker, endMarker); - this.taoInvalidReason = 'verifyErrorExistsBetweenMarkers NYI'; + this.taoInvalidReason = "verifyErrorExistsBetweenMarkers NYI"; if (exists !== negative) { this.printErrorLog(negative, this.getAllDiagnostics()); @@ -492,7 +514,7 @@ module FourSlash { }; } - this.taoInvalidReason = 'verifyErrorExistsAfterMarker NYI'; + this.taoInvalidReason = "verifyErrorExistsAfterMarker NYI"; let exists = this.anyErrorInRange(predicate, marker); let diagnostics = this.getAllDiagnostics(); @@ -533,7 +555,7 @@ module FourSlash { errors.forEach(function (error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + - ", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n"); + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); }); } @@ -541,7 +563,7 @@ module FourSlash { let errors = this.getDiagnostics(this.activeFile.fileName); let actual = errors.length; - this.scenarioActions.push(''); + this.scenarioActions.push(``); if (actual !== expected) { this.printErrorLog(false, errors); @@ -557,11 +579,11 @@ module FourSlash { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } - this.taoInvalidReason = 'verifyEval impossible'; + this.taoInvalidReason = "verifyEval impossible"; - let evaluation = new Function(emit.outputFiles[0].text + ';\r\nreturn (' + expr + ');')(); + let evaluation = new Function(`${emit.outputFiles[0].text};\r\nreturn (${expr});`)(); if (evaluation !== value) { - this.raiseError('Expected evaluation of expression "' + expr + '" to equal "' + value + '", but got "' + evaluation + '"'); + this.raiseError(`Expected evaluation of expression "${expr}" to equal "${value}", but got "${evaluation}"`); } } @@ -570,19 +592,19 @@ module FourSlash { if (emit.outputFiles.length !== 1) { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } - this.taoInvalidReason = 'verifyGetEmitOutputForCurrentFile impossible'; + this.taoInvalidReason = "verifyGetEmitOutputForCurrentFile impossible"; let actual = emit.outputFiles[0].text; if (actual !== expected) { - this.raiseError("Expected emit output to be '" + expected + "', but got '" + actual + "'"); + this.raiseError(`Expected emit output to be "${expected}", but got "${actual}"`); } } public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); if (text || documentation || kind) { - this.taoInvalidReason = 'verifyMemberListContains only supports the "symbol" parameter'; + this.taoInvalidReason = "verifyMemberListContains only supports the \"symbol\" parameter"; } let members = this.getMemberListAtCaret(); @@ -600,11 +622,11 @@ module FourSlash { this.verifyMemberListIsEmpty(false); return; } else { - this.scenarioActions.push(''); + this.scenarioActions.push(""); } } else { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); } let members = this.getMemberListAtCaret(); @@ -622,31 +644,31 @@ module FourSlash { } public verifyMemberListDoesNotContain(symbol: string) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); let members = this.getMemberListAtCaret(); if (members && members.entries.filter(e => e.name === symbol).length !== 0) { - this.raiseError('Member list did contain ' + symbol); + this.raiseError(`Member list did contain ${symbol}`); } } public verifyCompletionListItemsCountIsGreaterThan(count: number) { - this.taoInvalidReason = 'verifyCompletionListItemsCountIsGreaterThan NYI'; + this.taoInvalidReason = "verifyCompletionListItemsCountIsGreaterThan NYI"; let completions = this.getCompletionListAtCaret(); let itemsCount = completions.entries.length; if (itemsCount <= count) { - this.raiseError('Expected completion list items count to be greater than ' + count + ', but is actually ' + itemsCount); + this.raiseError(`Expected completion list items count to be greater than ${count}, but is actually ${itemsCount}`); } } public verifyMemberListIsEmpty(negative: boolean) { if (negative) { - this.scenarioActions.push(''); + this.scenarioActions.push(""); } else { - this.scenarioActions.push(''); + this.scenarioActions.push(""); } let members = this.getMemberListAtCaret(); @@ -666,7 +688,7 @@ module FourSlash { } public verifyCompletionListIsEmpty(negative: boolean) { - this.scenarioActions.push(''); + this.scenarioActions.push(""); let completions = this.getCompletionListAtCaret(); if ((!completions || completions.entries.length === 0) && negative) { @@ -730,12 +752,12 @@ module FourSlash { return documentation === expectedDocumentation ? true : false; } // Because expectedText and expectedDocumentation are undefined, we assume that - // users don't care to compare them so we will treat that entry as if the entry has matching text and documentation + // users don"t care to compare them so we will treat that entry as if the entry has matching text and documentation // and keep it in the list of filtered entry. return true; } - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); let completions = this.getCompletionListAtCaret(); if (completions) { @@ -763,7 +785,7 @@ module FourSlash { } public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { - this.taoInvalidReason = 'verifyCompletionEntryDetails NYI'; + this.taoInvalidReason = "verifyCompletionEntryDetails NYI"; let details = this.getCompletionEntryDetails(entryName); @@ -779,30 +801,30 @@ module FourSlash { } public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { - this.taoInvalidReason = 'verifyReferencesAtPositionListContains NYI'; + this.taoInvalidReason = "verifyReferencesAtPositionListContains NYI"; let references = this.getReferencesAtCaret(); if (!references || references.length === 0) { - this.raiseError('verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.'); + this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one."); } for (let i = 0; i < references.length; i++) { let reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { - this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); + this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`); } return; } } let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; - this.raiseError('verifyReferencesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(references) + ')'); + this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(references)})`); } public verifyReferencesCountIs(count: number, localFilesOnly: boolean = true) { - this.taoInvalidReason = 'verifyReferences NYI'; + this.taoInvalidReason = "verifyReferences NYI"; let references = this.getReferencesAtCaret(); let referencesCount = 0; @@ -865,8 +887,8 @@ module FourSlash { public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) { [expectedText, expectedDocumentation].forEach(str => { if (str) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); } }); @@ -896,8 +918,8 @@ module FourSlash { public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; }, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[]) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); function getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) { let result = ""; @@ -964,23 +986,23 @@ module FourSlash { } public verifyQuickInfoExists(negative: boolean) { - this.taoInvalidReason = 'verifyQuickInfoExists NYI'; + this.taoInvalidReason = "verifyQuickInfoExists NYI"; let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (negative) { if (actualQuickInfo) { - this.raiseError('verifyQuickInfoExists failed. Expected quick info NOT to exist'); + this.raiseError("verifyQuickInfoExists failed. Expected quick info NOT to exist"); } } else { if (!actualQuickInfo) { - this.raiseError('verifyQuickInfoExists failed. Expected quick info to exist'); + this.raiseError("verifyQuickInfoExists failed. Expected quick info to exist"); } } } public verifyCurrentSignatureHelpIs(expected: string) { - this.taoInvalidReason = 'verifyCurrentSignatureHelpIs NYI'; + this.taoInvalidReason = "verifyCurrentSignatureHelpIs NYI"; let help = this.getActiveSignatureHelpItem(); assert.equal( @@ -990,7 +1012,7 @@ module FourSlash { } public verifyCurrentParameterIsletiable(isVariable: boolean) { - this.taoInvalidReason = 'verifyCurrentParameterIsletiable NYI'; + this.taoInvalidReason = "verifyCurrentParameterIsletiable NYI"; let signature = this.getActiveSignatureHelpItem(); assert.isNotNull(signature); @@ -998,7 +1020,7 @@ module FourSlash { } public verifyCurrentParameterHelpName(name: string) { - this.taoInvalidReason = 'verifyCurrentParameterHelpName NYI'; + this.taoInvalidReason = "verifyCurrentParameterHelpName NYI"; let activeParameter = this.getActiveParameter(); let activeParameterName = activeParameter.name; @@ -1006,7 +1028,7 @@ module FourSlash { } public verifyCurrentParameterSpanIs(parameter: string) { - this.taoInvalidReason = 'verifyCurrentParameterSpanIs NYI'; + this.taoInvalidReason = "verifyCurrentParameterSpanIs NYI"; let activeSignature = this.getActiveSignatureHelpItem(); let activeParameter = this.getActiveParameter(); @@ -1014,7 +1036,7 @@ module FourSlash { } public verifyCurrentParameterHelpDocComment(docComment: string) { - this.taoInvalidReason = 'verifyCurrentParameterHelpDocComment NYI'; + this.taoInvalidReason = "verifyCurrentParameterHelpDocComment NYI"; let activeParameter = this.getActiveParameter(); let activeParameterDocComment = activeParameter.documentation; @@ -1022,27 +1044,27 @@ module FourSlash { } public verifyCurrentSignatureHelpParameterCount(expectedCount: number) { - this.taoInvalidReason = 'verifyCurrentSignatureHelpParameterCount NYI'; + this.taoInvalidReason = "verifyCurrentSignatureHelpParameterCount NYI"; assert.equal(this.getActiveSignatureHelpItem().parameters.length, expectedCount); } public verifyCurrentSignatureHelpTypeParameterCount(expectedCount: number) { - this.taoInvalidReason = 'verifyCurrentSignatureHelpTypeParameterCount NYI'; + this.taoInvalidReason = "verifyCurrentSignatureHelpTypeParameterCount NYI"; // assert.equal(this.getActiveSignatureHelpItem().typeParameters.length, expectedCount); } public verifyCurrentSignatureHelpDocComment(docComment: string) { - this.taoInvalidReason = 'verifyCurrentSignatureHelpDocComment NYI'; + this.taoInvalidReason = "verifyCurrentSignatureHelpDocComment NYI"; let actualDocComment = this.getActiveSignatureHelpItem().documentation; assert.equal(ts.displayPartsToString(actualDocComment), docComment, assertionMessage("current signature help doc comment")); } public verifySignatureHelpCount(expected: number) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); let actual = help && help.items ? help.items.length : 0; @@ -1050,14 +1072,14 @@ module FourSlash { } public verifySignatureHelpArgumentCount(expected: number) { - this.taoInvalidReason = 'verifySignatureHelpArgumentCount NYI'; + this.taoInvalidReason = "verifySignatureHelpArgumentCount NYI"; let signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); let actual = signatureHelpItems.argumentCount; assert.equal(actual, expected); } public verifySignatureHelpPresent(shouldBePresent = true) { - this.taoInvalidReason = 'verifySignatureHelpPresent NYI'; + this.taoInvalidReason = "verifySignatureHelpPresent NYI"; let actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); if (shouldBePresent) { @@ -1066,7 +1088,7 @@ module FourSlash { } } else { if (actual) { - this.raiseError("Expected no signature help, but got '" + JSON.stringify(actual) + "'"); + this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`); } } } @@ -1200,12 +1222,12 @@ module FourSlash { } public getBreakpointStatementLocation(pos: number) { - this.taoInvalidReason = 'getBreakpointStatementLocation NYI'; + this.taoInvalidReason = "getBreakpointStatementLocation NYI"; return this.languageService.getBreakpointStatementAtPosition(this.activeFile.fileName, pos); } public baselineCurrentFileBreakpointLocations() { - this.taoInvalidReason = 'baselineCurrentFileBreakpointLocations impossible'; + this.taoInvalidReason = "baselineCurrentFileBreakpointLocations impossible"; Harness.Baseline.runBaseline( "Breakpoint Locations for " + this.activeFile.fileName, @@ -1217,7 +1239,7 @@ module FourSlash { } public baselineGetEmitOutput() { - this.taoInvalidReason = 'baselineGetEmitOutput impossible'; + this.taoInvalidReason = "baselineGetEmitOutput impossible"; // Find file to be emitted let emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on @@ -1244,21 +1266,21 @@ module FourSlash { emitFiles.forEach(emitFile => { let emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format - resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine; + resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); if (emitOutput.emitSkipped) { - resultString += "Diagnostics:" + ts.sys.newLine; + resultString += "Diagnostics:" + Harness.IO.newLine(); let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); for (let i = 0, n = diagnostics.length; i < n; i++) { - resultString += " " + diagnostics[0].messageText + ts.sys.newLine; + resultString += " " + diagnostics[0].messageText + Harness.IO.newLine(); } } emitOutput.outputFiles.forEach((outputFile, idx, array) => { - let fileName = "FileName : " + outputFile.name + ts.sys.newLine; + let fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; }); - resultString += ts.sys.newLine; + resultString += Harness.IO.newLine(); }); return resultString; @@ -1288,14 +1310,14 @@ module FourSlash { let syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); let semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); let errorList = syntacticErrors.concat(semanticErrors); - Harness.IO.log('Error list (' + errorList.length + ' errors)'); + Harness.IO.log(`Error list (${errorList.length} errors)`); if (errorList.length) { errorList.forEach(err => { Harness.IO.log( "start: " + err.start + ", length: " + err.length + - ", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine)); + ", message: " + ts.flattenDiagnosticMessageText(err.messageText, Harness.IO.newLine())); }); } } @@ -1304,10 +1326,10 @@ module FourSlash { for (let i = 0; i < this.testData.files.length; i++) { let file = this.testData.files[i]; let active = (this.activeFile === file); - Harness.IO.log('=== Script (' + file.fileName + ') ' + (active ? '(active, cursor at |)' : '') + ' ==='); + Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`); let content = this.getFileContent(file.fileName); if (active) { - content = content.substr(0, this.currentCaretPosition) + (makeCaretVisible ? '|' : "") + content.substr(this.currentCaretPosition); + content = content.substr(0, this.currentCaretPosition) + (makeCaretVisible ? "|" : "") + content.substr(this.currentCaretPosition); } if (makeWhitespaceVisible) { content = TestState.makeWhitespaceVisible(content); @@ -1343,7 +1365,7 @@ module FourSlash { } public deleteChar(count = 1) { - this.scenarioActions.push(''); + this.scenarioActions.push(``); let offset = this.currentCaretPosition; let ch = ""; @@ -1377,7 +1399,7 @@ module FourSlash { } public replace(start: number, length: number, text: string) { - this.taoInvalidReason = 'replace NYI'; + this.taoInvalidReason = "replace NYI"; this.languageServiceAdapterHost.editScript(this.activeFile.fileName, start, start + length, text); this.updateMarkersForEdit(this.activeFile.fileName, start, start + length, text); @@ -1385,7 +1407,7 @@ module FourSlash { } public deleteCharBehindMarker(count = 1) { - this.scenarioActions.push(''); + this.scenarioActions.push(``); let offset = this.currentCaretPosition; let ch = ""; @@ -1419,10 +1441,10 @@ module FourSlash { // Enters lines of text at the current caret position public type(text: string) { - if (text === '') { - this.taoInvalidReason = 'Test used empty-insert workaround.'; + if (text === "") { + this.taoInvalidReason = "Test used empty-insert workaround."; } else { - this.scenarioActions.push(''); + this.scenarioActions.push(``); } return this.typeHighFidelity(text); @@ -1433,7 +1455,7 @@ module FourSlash { // as much as possible private typeHighFidelity(text: string) { let offset = this.currentCaretPosition; - let prevChar = ' '; + let prevChar = " "; let checkCadence = (text.length >> 2) + 1; for (let i = 0; i < text.length; i++) { @@ -1445,10 +1467,10 @@ module FourSlash { this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch); offset++; - if (ch === '(' || ch === ',') { + if (ch === "(" || ch === ",") { /* Signature help*/ this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); - } else if (prevChar === ' ' && /A-Za-z_/.test(ch)) { + } else if (prevChar === " " && /A-Za-z_/.test(ch)) { /* Completions */ this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); } @@ -1478,7 +1500,7 @@ module FourSlash { // Enters text as if the user had pasted it public paste(text: string) { - this.scenarioActions.push(''); + this.scenarioActions.push(``); let start = this.currentCaretPosition; let offset = this.currentCaretPosition; @@ -1531,7 +1553,7 @@ module FourSlash { // that happens, move it back one character if (this.currentCaretPosition > 0) { let ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); - if (ch === '\r') { + if (ch === "\r") { this.currentCaretPosition--; } }; @@ -1556,8 +1578,8 @@ module FourSlash { if (isFormattingEdit) { let newContent = this.getFileContent(fileName); - if (newContent.replace(/\s/g, '') !== oldContent.replace(/\s/g, '')) { - this.raiseError('Formatting operation destroyed non-whitespace content'); + if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) { + this.raiseError("Formatting operation destroyed non-whitespace content"); } } return runningOffset; @@ -1574,7 +1596,7 @@ module FourSlash { } public formatDocument() { - this.scenarioActions.push(''); + this.scenarioActions.push(""); let edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); @@ -1582,7 +1604,7 @@ module FourSlash { } public formatSelection(start: number, end: number) { - this.taoInvalidReason = 'formatSelection NYI'; + this.taoInvalidReason = "formatSelection NYI"; let edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); @@ -1617,18 +1639,18 @@ module FourSlash { public goToDefinition(definitionIndex: number) { if (definitionIndex === 0) { - this.scenarioActions.push(''); + this.scenarioActions.push(""); } else { - this.taoInvalidReason = 'GoToDefinition not supported for non-zero definition indices'; + this.taoInvalidReason = "GoToDefinition not supported for non-zero definition indices"; } let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { - this.raiseError('goToDefinition failed - expected to at least one definition location but got 0'); + this.raiseError("goToDefinition failed - expected to at least one definition location but got 0"); } if (definitionIndex >= definitions.length) { - this.raiseError('goToDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')'); + this.raiseError(`goToDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`); } let definition = definitions[definitionIndex]; @@ -1638,19 +1660,19 @@ module FourSlash { public goToTypeDefinition(definitionIndex: number) { if (definitionIndex === 0) { - this.scenarioActions.push(''); + this.scenarioActions.push(""); } else { - this.taoInvalidReason = 'GoToTypeDefinition not supported for non-zero definition indices'; + this.taoInvalidReason = "GoToTypeDefinition not supported for non-zero definition indices"; } let definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { - this.raiseError('goToTypeDefinition failed - expected to at least one definition location but got 0'); + this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0"); } if (definitionIndex >= definitions.length) { - this.raiseError('goToTypeDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')'); + this.raiseError(`goToTypeDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`); } let definition = definitions[definitionIndex]; @@ -1659,17 +1681,17 @@ module FourSlash { } public verifyDefinitionLocationExists(negative: boolean) { - this.taoInvalidReason = 'verifyDefinitionLocationExists NYI'; + this.taoInvalidReason = "verifyDefinitionLocationExists NYI"; let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); let foundDefinitions = definitions && definitions.length; if (foundDefinitions && negative) { - this.raiseError('goToDefinition - expected to 0 definition locations but got ' + definitions.length); + this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`); } else if (!foundDefinitions && !negative) { - this.raiseError('goToDefinition - expected to at least one definition location but got 0'); + this.raiseError("goToDefinition - expected to at least one definition location but got 0"); } } @@ -1692,7 +1714,7 @@ module FourSlash { } public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) { - this.taoInvalidReason = 'verifyDefinititionsInfo NYI'; + this.taoInvalidReason = "verifyDefinititionsInfo NYI"; let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); let actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; @@ -1716,15 +1738,15 @@ module FourSlash { return this.testData.ranges.slice(0); } - public verifyCaretAtMarker(markerName = '') { - this.taoInvalidReason = 'verifyCaretAtMarker NYI'; + public verifyCaretAtMarker(markerName = "") { + this.taoInvalidReason = "verifyCaretAtMarker NYI"; let pos = this.getMarkerByName(markerName); if (pos.fileName !== this.activeFile.fileName) { - throw new Error('verifyCaretAtMarker failed - expected to be in file "' + pos.fileName + '", but was in file "' + this.activeFile.fileName + '"'); + throw new Error(`verifyCaretAtMarker failed - expected to be in file "${pos.fileName}", but was in file "${this.activeFile.fileName}"`); } if (pos.position !== this.currentCaretPosition) { - throw new Error('verifyCaretAtMarker failed - expected to be at marker "/*' + markerName + '*/, but was at position ' + this.currentCaretPosition + '(' + this.getLineColStringAtPosition(this.currentCaretPosition) + ')'); + throw new Error(`verifyCaretAtMarker failed - expected to be at marker "/*${markerName}*/, but was at position ${this.currentCaretPosition}(${this.getLineColStringAtPosition(this.currentCaretPosition)})`); } } @@ -1733,84 +1755,84 @@ module FourSlash { } public verifyIndentationAtCurrentPosition(numberOfSpaces: number) { - this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI'; + this.taoInvalidReason = "verifyIndentationAtCurrentPosition NYI"; let actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition); let lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); if (actual !== numberOfSpaces) { - this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); + this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); } } public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number) { - this.taoInvalidReason = 'verifyIndentationAtPosition NYI'; + this.taoInvalidReason = "verifyIndentationAtPosition NYI"; let actual = this.getIndentation(fileName, position); let lineCol = this.getLineColStringAtPosition(position); if (actual !== numberOfSpaces) { - this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); + this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); } } public verifyCurrentLineContent(text: string) { - this.taoInvalidReason = 'verifyCurrentLineContent NYI'; + this.taoInvalidReason = "verifyCurrentLineContent NYI"; let actual = this.getCurrentLineContent(); if (actual !== text) { - throw new Error('verifyCurrentLineContent\n' + - '\tExpected: "' + text + '"\n' + - '\t Actual: "' + actual + '"'); + throw new Error("verifyCurrentLineContent\n" + + "\tExpected: \"" + text + "\"\n" + + "\t Actual: \"" + actual + "\""); } } public verifyCurrentFileContent(text: string) { - this.taoInvalidReason = 'verifyCurrentFileContent NYI'; + this.taoInvalidReason = "verifyCurrentFileContent NYI"; let actual = this.getFileContent(this.activeFile.fileName); let replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); if (replaceNewlines(actual) !== replaceNewlines(text)) { - throw new Error('verifyCurrentFileContent\n' + - '\tExpected: "' + text + '"\n' + - '\t Actual: "' + actual + '"'); + throw new Error("verifyCurrentFileContent\n" + + "\tExpected: \"" + text + "\"\n" + + "\t Actual: \"" + actual + "\""); } } public verifyTextAtCaretIs(text: string) { - this.taoInvalidReason = 'verifyCurrentFileContent NYI'; + this.taoInvalidReason = "verifyCurrentFileContent NYI"; let actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); if (actual !== text) { - throw new Error('verifyTextAtCaretIs\n' + - '\tExpected: "' + text + '"\n' + - '\t Actual: "' + actual + '"'); + throw new Error("verifyTextAtCaretIs\n" + + "\tExpected: \"" + text + "\"\n" + + "\t Actual: \"" + actual + "\""); } } public verifyCurrentNameOrDottedNameSpanText(text: string) { - this.taoInvalidReason = 'verifyCurrentNameOrDottedNameSpanText NYI'; + this.taoInvalidReason = "verifyCurrentNameOrDottedNameSpanText NYI"; let span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); if (!span) { - this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' + - '\tExpected: "' + text + '"\n' + - '\t Actual: undefined'); + this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + + "\tExpected: \"" + text + "\"\n" + + "\t Actual: undefined"); } let actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); if (actual !== text) { - this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' + - '\tExpected: "' + text + '"\n' + - '\t Actual: "' + actual + '"'); + this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + + "\tExpected: \"" + text + "\"\n" + + "\t Actual: \"" + actual + "\""); } } private getNameOrDottedNameSpan(pos: number) { - this.taoInvalidReason = 'getNameOrDottedNameSpan NYI'; + this.taoInvalidReason = "getNameOrDottedNameSpan NYI"; return this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, pos, pos); } public baselineCurrentFileNameOrDottedNameSpans() { - this.taoInvalidReason = 'baselineCurrentFileNameOrDottedNameSpans impossible'; + this.taoInvalidReason = "baselineCurrentFileNameOrDottedNameSpans impossible"; Harness.Baseline.runBaseline( "Name OrDottedNameSpans for " + this.activeFile.fileName, @@ -1828,8 +1850,8 @@ module FourSlash { private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) { if (actual.length !== expected.length) { - this.raiseError('verifyClassifications failed - expected total classifications to be ' + expected.length + - ', but was ' + actual.length + + this.raiseError("verifyClassifications failed - expected total classifications to be " + expected.length + + ", but was " + actual.length + jsonMismatchString()); } @@ -1839,8 +1861,8 @@ module FourSlash { let expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; if (expectedType !== actualClassification.classificationType) { - this.raiseError('verifyClassifications failed - expected classifications type to be ' + - expectedType + ', but was ' + + this.raiseError("verifyClassifications failed - expected classifications type to be " + + expectedType + ", but was " + actualClassification.classificationType + jsonMismatchString()); } @@ -1861,17 +1883,17 @@ module FourSlash { let actualText = this.activeFile.content.substr(actualSpan.start, actualSpan.length); if (expectedClassification.text !== actualText) { - this.raiseError('verifyClassifications failed - expected classified text to be ' + - expectedClassification.text + ', but was ' + + this.raiseError("verifyClassifications failed - expected classified text to be " + + expectedClassification.text + ", but was " + actualText + jsonMismatchString()); } } function jsonMismatchString() { - return ts.sys.newLine + - "expected: '" + ts.sys.newLine + JSON.stringify(expected, (k, v) => v, 2) + "'" + ts.sys.newLine + - "actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'"; + return Harness.IO.newLine() + + "expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() + + "actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'"; } } @@ -1883,7 +1905,7 @@ module FourSlash { ); assert.equal( expected.join(","), - actual.fileNameList.map( file => { + actual.fileNames.map( file => { return file.replace(this.basePath + "/", ""); }).join(",") ); @@ -1905,19 +1927,19 @@ module FourSlash { } public verifyOutliningSpans(spans: TextSpan[]) { - this.taoInvalidReason = 'verifyOutliningSpans NYI'; + this.taoInvalidReason = "verifyOutliningSpans NYI"; let actual = this.languageService.getOutliningSpans(this.activeFile.fileName); if (actual.length !== spans.length) { - this.raiseError('verifyOutliningSpans failed - expected total spans to be ' + spans.length + ', but was ' + actual.length); + this.raiseError(`verifyOutliningSpans failed - expected total spans to be ${spans.length}, but was ${actual.length}`); } for (let i = 0; i < spans.length; i++) { let expectedSpan = spans[i]; let actualSpan = actual[i]; if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) { - this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.textSpan.start + ',' + ts.textSpanEnd(actualSpan.textSpan) + ')'); + this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`); } } } @@ -1927,7 +1949,7 @@ module FourSlash { descriptors.map(d => { return { text: d, priority: 0 }; })); if (actual.length !== spans.length) { - this.raiseError('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length); + this.raiseError(`verifyTodoComments failed - expected total spans to be ${spans.length}, but was ${actual.length}`); } for (let i = 0; i < spans.length; i++) { @@ -1936,18 +1958,44 @@ module FourSlash { let actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) { - this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualCommentSpan.start + ',' + ts.textSpanEnd(actualCommentSpan) + ')'); + this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`); + } + } + } + + public verifyDocCommentTemplate(expected?: ts.TextInsertion) { + const name = "verifyDocCommentTemplate"; + let actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); + + if (expected === undefined) { + if (actual) { + this.raiseError(name + ' failed - expected no template but got {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '}'); + } + + return; + } + else { + if (actual === undefined) { + this.raiseError(name + ' failed - expected the template {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '} but got nothing instead'); + } + + if (actual.newText !== expected.newText) { + this.raiseError(name + ' failed - expected insertion:\n' + expected.newText + '\nactual insertion:\n' + actual.newText); + } + + if (actual.caretOffset !== expected.caretOffset) { + this.raiseError(name + ' failed - expected caretOffset: ' + expected.caretOffset + ',\nactual caretOffset:' + actual.caretOffset); } } } public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { - this.taoInvalidReason = 'verifyMatchingBracePosition NYI'; + this.taoInvalidReason = "verifyMatchingBracePosition NYI"; let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 2) { - this.raiseError('verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ' + actual.length); + this.raiseError(`verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ${actual.length}`); } let actualMatchPosition = -1; @@ -1956,21 +2004,21 @@ module FourSlash { } else if (bracePosition === actual[1].start) { actualMatchPosition = actual[0].start; } else { - this.raiseError('verifyMatchingBracePosition failed - could not find the brace position: ' + bracePosition + ' in the returned list: (' + actual[0].start + ',' + ts.textSpanEnd(actual[0]) + ') and (' + actual[1].start + ',' + ts.textSpanEnd(actual[1]) + ')'); + this.raiseError(`verifyMatchingBracePosition failed - could not find the brace position: ${bracePosition} in the returned list: (${actual[0].start},${ts.textSpanEnd(actual[0])}) and (${actual[1].start},${ts.textSpanEnd(actual[1])})`); } if (actualMatchPosition !== expectedMatchPosition) { - this.raiseError('verifyMatchingBracePosition failed - expected: ' + actualMatchPosition + ', actual: ' + expectedMatchPosition); + this.raiseError(`verifyMatchingBracePosition failed - expected: ${actualMatchPosition}, actual: ${expectedMatchPosition}`); } } public verifyNoMatchingBracePosition(bracePosition: number) { - this.taoInvalidReason = 'verifyNoMatchingBracePosition NYI'; + this.taoInvalidReason = "verifyNoMatchingBracePosition NYI"; let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 0) { - this.raiseError('verifyNoMatchingBracePosition failed - expected: 0 spans, actual: ' + actual.length); + this.raiseError("verifyNoMatchingBracePosition failed - expected: 0 spans, actual: " + actual.length); } } @@ -1979,7 +2027,7 @@ module FourSlash { Report an error if expected value and actual value do not match. */ public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string) { - this.taoInvalidReason = 'verifyNavigationItemsCount NYI'; + this.taoInvalidReason = "verifyNavigationItemsCount NYI"; let items = this.languageService.getNavigateToItems(searchValue); let actual = 0; @@ -1994,7 +2042,7 @@ module FourSlash { } if (expected !== actual) { - this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.'); + this.raiseError(`verifyNavigationItemsCount failed - found: ${actual} navigation items, expected: ${expected}.`); } } @@ -2009,12 +2057,12 @@ module FourSlash { matchKind: string, fileName?: string, parentName?: string) { - this.taoInvalidReason = 'verifyNavigationItemsListContains NYI'; + this.taoInvalidReason = "verifyNavigationItemsListContains NYI"; let items = this.languageService.getNavigateToItems(searchValue); if (!items || items.length === 0) { - this.raiseError('verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.'); + this.raiseError("verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one."); } for (let i = 0; i < items.length; i++) { @@ -2030,18 +2078,18 @@ module FourSlash { // if there was an explicit match kind specified, then it should be validated. if (matchKind !== undefined) { let missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; - this.raiseError('verifyNavigationItemsListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')'); + this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items)})`); } } public verifyGetScriptLexicalStructureListCount(expected: number) { - this.taoInvalidReason = 'verifyNavigationItemsListContains impossible'; + this.taoInvalidReason = "verifyNavigationItemsListContains impossible"; let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); let actual = this.getNavigationBarItemsCount(items); if (expected !== actual) { - this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.'); + this.raiseError(`verifyGetScriptLexicalStructureListCount failed - found: ${actual} navigation items, expected: ${expected}.`); } } @@ -2058,12 +2106,12 @@ module FourSlash { } public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { - this.taoInvalidReason = 'verifyGetScriptLexicalStructureListContains impossible'; + this.taoInvalidReason = "verifyGetScriptLexicalStructureListContains impossible"; let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); if (!items || items.length === 0) { - this.raiseError('verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one.'); + this.raiseError("verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one."); } if (this.navigationBarItemsContains(items, name, kind)) { @@ -2071,7 +2119,7 @@ module FourSlash { } let missingItem = { name: name, kind: kind }; - this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items, null, " ") + ')'); + this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items, null, " ")})`); } private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { @@ -2095,11 +2143,11 @@ module FourSlash { let items = this.languageService.getNavigateToItems(searchValue); let length = items && items.length; - Harness.IO.log('NavigationItems list (' + length + ' items)'); + Harness.IO.log(`NavigationItems list (${length} items)`); for (let i = 0; i < length; i++) { let item = items[i]; - Harness.IO.log('name: ' + item.name + ', kind: ' + item.kind + ', parentName: ' + item.containerName + ', fileName: ' + item.fileName); + Harness.IO.log(`name: ${item.name}, kind: ${item.kind}, parentName: ${item.containerName}, fileName: ${item.fileName}`); } } @@ -2107,48 +2155,93 @@ module FourSlash { let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); let length = items && items.length; - Harness.IO.log('NavigationItems list (' + length + ' items)'); + Harness.IO.log(`NavigationItems list (${length} items)`); for (let i = 0; i < length; i++) { let item = items[i]; - Harness.IO.log('name: ' + item.text + ', kind: ' + item.kind); + Harness.IO.log(`name: ${item.text}, kind: ${item.kind}`); } } - private getOccurancesAtCurrentPosition() { + private getOccurrencesAtCurrentPosition() { return this.languageService.getOccurrencesAtPosition(this.activeFile.fileName, this.currentCaretPosition); } public verifyOccurrencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { - this.taoInvalidReason = 'verifyOccurrencesAtPositionListContains NYI'; + this.taoInvalidReason = "verifyOccurrencesAtPositionListContains NYI"; - let occurances = this.getOccurancesAtCurrentPosition(); + let occurrences = this.getOccurrencesAtCurrentPosition(); - if (!occurances || occurances.length === 0) { - this.raiseError('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.'); + if (!occurrences || occurrences.length === 0) { + this.raiseError('verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one.'); } - for (let i = 0; i < occurances.length; i++) { - let occurance = occurances[i]; - if (occurance && occurance.fileName === fileName && occurance.textSpan.start === start && ts.textSpanEnd(occurance.textSpan) === end) { - if (typeof isWriteAccess !== "undefined" && occurance.isWriteAccess !== isWriteAccess) { - this.raiseError('verifyOccurancesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + occurance.isWriteAccess + ', expected: ' + isWriteAccess + '.'); + for (let occurrence of occurrences) { + if (occurrence && occurrence.fileName === fileName && occurrence.textSpan.start === start && ts.textSpanEnd(occurrence.textSpan) === end) { + if (typeof isWriteAccess !== "undefined" && occurrence.isWriteAccess !== isWriteAccess) { + this.raiseError(`verifyOccurrencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${occurrence.isWriteAccess}, expected: ${isWriteAccess}.`); } return; } } let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; - this.raiseError('verifyOccurancesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(occurances) + ')'); + this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(occurrences)})`); } public verifyOccurrencesAtPositionListCount(expectedCount: number) { - this.taoInvalidReason = 'verifyOccurrencesAtPositionListCount NYI'; + this.taoInvalidReason = "verifyOccurrencesAtPositionListCount NYI"; - let occurances = this.getOccurancesAtCurrentPosition(); - let actualCount = occurances ? occurances.length : 0; + let occurrences = this.getOccurrencesAtCurrentPosition(); + let actualCount = occurrences ? occurrences.length : 0; if (expectedCount !== actualCount) { - this.raiseError('verifyOccurrencesAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount); + this.raiseError(`verifyOccurrencesAtPositionListCount failed - actual: ${actualCount}, expected:${expectedCount}`); + } + } + + private getDocumentHighlightsAtCurrentPosition(fileNamesToSearch: string[]) { + let filesToSearch = fileNamesToSearch.map(name => ts.combinePaths(this.basePath, name)); + return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); + } + + public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) { + this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListContains NYI'; + + let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); + + if (!documentHighlights || documentHighlights.length === 0) { + this.raiseError('verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one.'); + } + + for (let documentHighlight of documentHighlights) { + if (documentHighlight.fileName === fileName) { + let { highlightSpans } = documentHighlight; + + for (let highlight of highlightSpans) { + if (highlight && highlight.textSpan.start === start && ts.textSpanEnd(highlight.textSpan) === end) { + if (typeof kind !== "undefined" && highlight.kind !== kind) { + this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - item "kind" value does not match, actual: ${highlight.kind}, expected: ${kind}.`); + } + return; + } + } + } + } + + let missingItem = { fileName: fileName, start: start, end: end, kind: kind }; + this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(documentHighlights)})`); + } + + public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { + this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListCount NYI'; + + let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); + let actualCount = documentHighlights + ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) + : 0; + + if (expectedCount !== actualCount) { + this.raiseError('verifyDocumentHighlightsAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount); } } @@ -2182,11 +2275,11 @@ module FourSlash { } private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) { - this.scenarioActions.push(''); - this.scenarioActions.push(''); + this.scenarioActions.push(""); + this.scenarioActions.push(``); if (text || documentation || kind) { - this.taoInvalidReason = 'assertItemInCompletionList only supports the "name" parameter'; + this.taoInvalidReason = "assertItemInCompletionList only supports the \"name\" parameter"; } for (let i = 0; i < items.length; i++) { @@ -2213,23 +2306,23 @@ module FourSlash { let itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); - this.raiseError('Expected "' + JSON.stringify({ name, text, documentation, kind }) + '" to be in list [' + itemsString + ']'); + this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind })}" to be in list [${itemsString}]`); } private findFile(indexOrName: any) { let result: FourSlashFile = null; - if (typeof indexOrName === 'number') { + if (typeof indexOrName === "number") { let index = indexOrName; if (index >= this.testData.files.length) { - throw new Error('File index (' + index + ') in openFile was out of range. There are only ' + this.testData.files.length + ' files in this test.'); + throw new Error(`File index (${index}) in openFile was out of range. There are only ${this.testData.files.length} files in this test.`); } else { result = this.testData.files[index]; } - } else if (typeof indexOrName === 'string') { + } else if (typeof indexOrName === "string") { let name = indexOrName; // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName - name = name.indexOf('/') === -1 ? (this.basePath + '/' + name) : name; + name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name; let availableNames: string[] = []; let foundIt = false; @@ -2246,10 +2339,10 @@ module FourSlash { } if (!foundIt) { - throw new Error('No test file named "' + name + '" exists. Available file names are:' + availableNames.join(', ')); + throw new Error(`No test file named "${name}" exists. Available file names are: ${availableNames.join(", ")}`); } } else { - throw new Error('Unknown argument type'); + throw new Error("Unknown argument type"); } return result; @@ -2257,7 +2350,7 @@ module FourSlash { private getLineColStringAtPosition(position: number) { let pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position); - return 'line ' + (pos.line + 1) + ', col ' + pos.character; + return `line ${(pos.line + 1)}, col ${pos.character}`; } public getMarkerByName(markerName: string) { @@ -2265,21 +2358,21 @@ module FourSlash { if (markerPos === undefined) { let markerNames: string[] = []; for (let m in this.testData.markerPositions) markerNames.push(m); - throw new Error('Unknown marker "' + markerName + '" Available markers: ' + markerNames.map(m => '"' + m + '"').join(', ')); + throw new Error(`Unknown marker "${markerName}" Available markers: ${markerNames.map(m => "\"" + m + "\"").join(", ")}`); } else { return markerPos; } } private static makeWhitespaceVisible(text: string) { - return text.replace(/ /g, '\u00B7').replace(/\r/g, '\u00B6').replace(/\n/g, '\u2193\n').replace(/\t/g, '\u2192\ '); + return text.replace(/ /g, "\u00B7").replace(/\r/g, "\u00B6").replace(/\n/g, "\u2193\n").replace(/\t/g, "\u2192\ "); } public getTestXmlData(): TestXmlData { return { actions: this.scenarioActions, invalidReason: this.taoInvalidReason, - originalName: '' + originalName: "" }; } @@ -2309,7 +2402,7 @@ module FourSlash { let host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }], (fn, contents) => fourslashJsOutput = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); let program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host); @@ -2323,7 +2416,7 @@ module FourSlash { currentTestState = new TestState(basePath, testType, testData); - let result = ''; + let result = ""; let host = Harness.Compiler.createCompilerHost( [ { unitName: Harness.Compiler.fourslashFileName, content: undefined }, @@ -2331,20 +2424,20 @@ module FourSlash { ], (fn, contents) => result = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); - let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); + let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); let sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); let diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); if (diagnostics.length > 0) { - throw new Error('Error compiling ' + fileName + ': ' + - diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join('\r\n')); + throw new Error(`Error compiling ${fileName}: ` + + diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); } program.emit(sourceFile); - result = result || ''; // Might have an empty fourslash file + result = result || ""; // Might have an empty fourslash file result = fourslashJsOutput + "\r\n" + result; @@ -2365,12 +2458,12 @@ module FourSlash { function chompLeadingSpace(content: string) { let lines = content.split("\n"); for (let i = 0; i < lines.length; i++) { - if ((lines[i].length !== 0) && (lines[i].charAt(0) !== ' ')) { + if ((lines[i].length !== 0) && (lines[i].charAt(0) !== " ")) { return content; } } - return lines.map(s => s.substr(1)).join('\n'); + return lines.map(s => s.substr(1)).join("\n"); } function parseTestData(basePath: string, contents: string, fileName: string): FourSlashData { @@ -2386,7 +2479,7 @@ module FourSlash { // Split up the input file by line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to string-based splitting instead and try to figure out the delimiting chars - let lines = contents.split('\n'); + let lines = contents.split("\n"); let markerPositions: MarkerMap = {}; let markers: Marker[] = []; @@ -2401,23 +2494,23 @@ module FourSlash { let line = lines[i]; let lineLength = line.length; - if (lineLength > 0 && line.charAt(lineLength - 1) === '\r') { + if (lineLength > 0 && line.charAt(lineLength - 1) === "\r") { line = line.substr(0, lineLength - 1); } - if (line.substr(0, 4) === '////') { + if (line.substr(0, 4) === "////") { // Subfile content line // Append to the current subfile content, inserting a newline needed if (currentFileContent === null) { - currentFileContent = ''; + currentFileContent = ""; } else { // End-of-line - currentFileContent = currentFileContent + '\n'; + currentFileContent = currentFileContent + "\n"; } currentFileContent = currentFileContent + line.substr(4); - } else if (line.substr(0, 2) === '//') { + } else if (line.substr(0, 2) === "//") { // Comment line, check for global/file @options and record them let match = optionRegex.exec(line.substr(2)); if (match) { @@ -2425,7 +2518,7 @@ module FourSlash { let fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); if (globalMetadataNamesIndex === -1) { if (fileMetadataNamesIndex === -1) { - throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', ')); + throw new Error(`Unrecognized metadata name "${match[1]}". Available global metadata names are: ${globalMetadataNames.join(", ")}; file metadata names are: ${fileMetadataNames.join(", ")}`); } else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { // Found an @FileName directive, if this is not the first then create a new subfile if (currentFileContent) { @@ -2441,7 +2534,7 @@ module FourSlash { currentFileName = fileName; } - currentFileName = basePath + '/' + match[2]; + currentFileName = basePath + "/" + match[2]; currentFileOptions[match[1]] = match[2]; } else { // Add other fileMetadata flag @@ -2456,7 +2549,7 @@ module FourSlash { } } // TODO: should be '==='? - } else if (line == '' || lineLength === 0) { + } else if (line == "" || lineLength === 0) { // Previously blank lines between fourslash content caused it to be considered as 2 files, // Remove this behavior since it just causes errors now } else { @@ -2476,6 +2569,17 @@ module FourSlash { } } + // @Filename is the only directive that can be used in a test that contains tsconfig.json file. + if (containTSConfigJson(files)) { + let directive = getNonFileNameOptionInFileList(files); + if (!directive) { + directive = getNonFileNameOptionInObject(globalOptions); + } + if (directive) { + throw Error("It is not allowed to use tsconfig.json along with directive '" + directive + "'"); + } + } + return { markerPositions, markers, @@ -2485,6 +2589,23 @@ module FourSlash { }; } + function containTSConfigJson(files: FourSlashFile[]): boolean { + return ts.forEach(files, f => f.fileOptions["Filename"] === "tsconfig.json"); + } + + function getNonFileNameOptionInFileList(files: FourSlashFile[]): string { + return ts.forEach(files, f => getNonFileNameOptionInObject(f.fileOptions)); + } + + function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string { + for (let option in optionObject) { + if (option !== metadataOptionNames.fileName) { + return option; + } + } + return undefined; + } + const enum State { none, inSlashStarMarker, @@ -2548,7 +2669,7 @@ module FourSlash { content = chompLeadingSpace(content); // Any slash-star comment with a character not in this string is not a marker. - let validMarkerChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_'; + let validMarkerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_"; /// The file content (minus metacharacters) so far let output: string = ""; @@ -2683,7 +2804,7 @@ module FourSlash { openMarker = null; state = State.none; } else if (validMarkerChars.indexOf(currentChar) < 0) { - if (currentChar === '*' && i < content.length - 1 && content.charAt(i + 1) === '/') { + if (currentChar === "*" && i < content.length - 1 && content.charAt(i + 1) === "/") { // The marker is about to be closed, ignore the 'invalid' char } else { // We've hit a non-valid marker character, so we were actually in a block comment @@ -2698,10 +2819,10 @@ module FourSlash { break; } - if (currentChar === '\n' && previousChar === '\r') { + if (currentChar === "\n" && previousChar === "\r") { // Ignore trailing \n after a \r continue; - } else if (currentChar === '\n' || currentChar === '\r') { + } else if (currentChar === "\n" || currentChar === "\r") { line++; column = 1; continue; @@ -2735,4 +2856,4 @@ module FourSlash { fileName: fileName }; } -} \ No newline at end of file +} diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index 05a11c4f52d..d30a30d88e3 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -1,10 +1,11 @@ -/// -/// -/// +/// +/// +/// const enum FourSlashTestType { Native, Shims, + ShimsWithPreprocess, Server } @@ -16,16 +17,20 @@ class FourSlashRunner extends RunnerBase { super(); switch (testType) { case FourSlashTestType.Native: - this.basePath = 'tests/cases/fourslash'; - this.testSuiteName = 'fourslash'; + this.basePath = "tests/cases/fourslash"; + this.testSuiteName = "fourslash"; break; case FourSlashTestType.Shims: - this.basePath = 'tests/cases/fourslash/shims'; - this.testSuiteName = 'fourslash-shims'; + this.basePath = "tests/cases/fourslash/shims"; + this.testSuiteName = "fourslash-shims"; + break; + case FourSlashTestType.ShimsWithPreprocess: + this.basePath = 'tests/cases/fourslash/shims-pp'; + this.testSuiteName = 'fourslash-shims-pp'; break; case FourSlashTestType.Server: - this.basePath = 'tests/cases/fourslash/server'; - this.testSuiteName = 'fourslash-server'; + this.basePath = "tests/cases/fourslash/server"; + this.testSuiteName = "fourslash-server"; break; } } @@ -35,25 +40,25 @@ class FourSlashRunner extends RunnerBase { this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); } - describe(this.testSuiteName + ' tests', () => { + describe(this.testSuiteName + " tests", () => { this.tests.forEach((fn: string) => { describe(fn, () => { fn = ts.normalizeSlashes(fn); - let justName = fn.replace(/^.*[\\\/]/, ''); + let justName = fn.replace(/^.*[\\\/]/, ""); // Convert to relative path - let testIndex = fn.indexOf('tests/'); + let testIndex = fn.indexOf("tests/"); if (testIndex >= 0) fn = fn.substr(testIndex); if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { - it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => { + it(this.testSuiteName + " test " + justName + " runs correctly", () => { FourSlash.runFourSlashTest(this.basePath, this.testType, fn); }); } }); }); - describe('Generate Tao XML', () => { + describe("Generate Tao XML", () => { let invalidReasons: any = {}; FourSlash.xmlData.forEach(xml => { if (xml.invalidReason !== null) { @@ -69,37 +74,37 @@ class FourSlashRunner extends RunnerBase { invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1); let lines: string[] = []; - lines.push(''); - lines.push(''); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); + lines.push("-->"); + lines.push(""); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); FourSlash.xmlData.forEach(xml => { if (xml.invalidReason !== null) { - lines.push(''); + lines.push(""); } else { - lines.push(' '); + lines.push(" "); xml.actions.forEach(action => { - lines.push(' ' + action); + lines.push(" " + action); }); - lines.push(' '); + lines.push(" "); } }); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(''); - Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n')); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(" "); + lines.push(""); + Harness.IO.writeFile("built/local/fourslash.xml", lines.join("\r\n")); }); }); } @@ -108,6 +113,6 @@ class FourSlashRunner extends RunnerBase { class GeneratedFourslashRunner extends FourSlashRunner { constructor(testType: FourSlashTestType) { super(testType); - this.basePath += '/generated/'; + this.basePath += "/generated/"; } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index b6c10071cb1..f65a4f88730 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -14,24 +14,26 @@ // limitations under the License. // -/// -/// -/// -/// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// +/// -var Buffer: BufferConstructor = require('buffer').Buffer; +// Block scoped definitions work poorly for global variables, temporarily enable var +/* tslint:disable:no-var-keyword */ // this will work in the browser via browserify -var _chai: typeof chai = require('chai'); +var _chai: typeof chai = require("chai"); var assert: typeof _chai.assert = _chai.assert; var expect: typeof _chai.expect = _chai.expect; declare var __dirname: string; // Node-specific var global = Function("return this").call(null); +/* tslint:enable:no-var-keyword */ module Utils { // Setup some globals based on the current environment @@ -52,9 +54,17 @@ module Utils { return ExecutionEnvironment.Node; } } - + export let currentExecutionEnvironment = getExecutionEnvironment(); + const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser + ? require("buffer").Buffer + : undefined; + + export function encodeString(s: string): string { + return Buffer ? (new Buffer(s)).toString("utf8") : s; + } + export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { let environment = getExecutionEnvironment(); switch (environment) { @@ -63,7 +73,7 @@ module Utils { eval(fileContents); break; case ExecutionEnvironment.Node: - let vm = require('vm'); + let vm = require("vm"); if (nodeContext) { vm.runInNewContext(fileContents, nodeContext, fileName); } else { @@ -71,7 +81,7 @@ module Utils { } break; default: - throw new Error('Unknown context'); + throw new Error("Unknown context"); } } @@ -80,9 +90,9 @@ module Utils { // Split up the input file by line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to use string-based splitting instead and try to figure out the delimiting chars - let lines = content.split('\r\n'); + let lines = content.split("\r\n"); if (lines.length === 1) { - lines = content.split('\n'); + lines = content.split("\n"); if (lines.length === 1) { lines = content.split("\r"); @@ -93,13 +103,13 @@ module Utils { /** Reads a file under /tests */ export function readTestFile(path: string) { - if (path.indexOf('tests') < 0) { + if (path.indexOf("tests") < 0) { path = "tests/" + path; } let content: string = undefined; try { - content = ts.sys.readFile(Harness.userSpecifiedRoot + path); + content = Harness.IO.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -187,7 +197,7 @@ module Utils { return { start: diagnostic.start, length: diagnostic.length, - messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine), + messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()), category: (ts).DiagnosticCategory[diagnostic.category], code: diagnostic.code }; @@ -320,8 +330,8 @@ module Utils { assert.equal(d1.start, d2.start, "d1.start !== d2.start"); assert.equal(d1.length, d2.length, "d1.length !== d2.length"); assert.equal( - ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine), - ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText"); + ts.flattenDiagnosticMessageText(d1.messageText, Harness.IO.newLine()), + ts.flattenDiagnosticMessageText(d2.messageText, Harness.IO.newLine()), "d1.messageText !== d2.messageText"); assert.equal(d1.category, d2.category, "d1.category !== d2.category"); assert.equal(d1.code, d2.code, "d1.code !== d2.code"); } @@ -388,7 +398,7 @@ module Utils { module Harness.Path { export function getFileName(fullPath: string) { - return fullPath.replace(/^.*[\\\/]/, ''); + return fullPath.replace(/^.*[\\\/]/, ""); } export function filePath(fullPath: string) { @@ -401,6 +411,10 @@ module Harness.Path { module Harness { export interface IO { + newLine(): string; + getCurrentDirectory(): string; + useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string; readFile(path: string): string; writeFile(path: string, contents: string): void; directoryName(path: string): string; @@ -411,8 +425,15 @@ module Harness { listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; } - + export var IO: IO; + + // harness always uses one kind of new line + const harnessNewLine = "\r\n"; + module IOImpl { declare class Enumerator { public atEnd(): boolean; @@ -428,13 +449,21 @@ module Harness { } else { fso = {}; } + + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export let directoryExists: typeof IO.directoryExists = fso.FolderExists; - export let fileExists: typeof IO.fileExists = fso.FileExists; - export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const directoryName: typeof IO.directoryName = fso.GetParentFolderName; + export const directoryExists: typeof IO.directoryExists = fso.FolderExists; + export const fileExists: typeof IO.fileExists = fso.FileExists; + export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; export function createDirectory(path: string) { if (directoryExists(path)) { @@ -484,16 +513,24 @@ module Harness { declare let require: any; let fs: any, pathModule: any; if (require) { - fs = require('fs'); - pathModule = require('path'); + fs = require("fs"); + pathModule = require("path"); } else { fs = pathModule = {}; } + + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let fileExists: typeof IO.fileExists = fs.existsSync; - export let log: typeof IO.log = console.log; + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const fileExists: typeof IO.fileExists = fs.existsSync; + export const log: typeof IO.log = s => console.log(s); export function createDirectory(path: string) { if (!directoryExists(path)) { @@ -558,9 +595,13 @@ module Harness { export module Network { let serverRoot = "http://localhost:8888/"; - // Unused? - let newLine = '\r\n'; - let currentDirectory = () => ''; + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => false; + export const getCurrentDirectory = () => ""; + export const args = () => []; + export const getExecutingFilePath = () => ""; + export const exit = (exitCode: number) => {}; + let supportsCodePage = () => false; module Http { @@ -606,12 +647,13 @@ module Harness { export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse { let xhr = new XMLHttpRequest(); try { - let actionMsg = '?action=' + action; - xhr.open('POST', url + actionMsg, false); - xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); + let actionMsg = "?action=" + action; + xhr.open("POST", url + actionMsg, false); + xhr.setRequestHeader("Access-Control-Allow-Origin", "*"); xhr.send(contents); } catch (e) { + log(`XHR Error: ${e}`); return { status: 500, responseText: null }; } @@ -624,7 +666,7 @@ module Harness { } export function deleteFile(path: string) { - Http.writeToServerSync(serverRoot + path, 'DELETE', null); + Http.writeToServerSync(serverRoot + path, "DELETE", null); } export function directoryExists(path: string): boolean { @@ -637,20 +679,21 @@ module Harness { if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) { dirPath = null; // path + fileName - } else if (dirPath.indexOf('.') === -1) { - dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); + } else if (dirPath.indexOf(".") === -1) { + dirPath = dirPath.substring(0, dirPath.lastIndexOf("/")); // path } else { // strip any trailing slash if (dirPath.match(/.*\/$/)) { dirPath = dirPath.substring(0, dirPath.length - 2); } - dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); + dirPath = dirPath.substring(0, dirPath.lastIndexOf("/")); } return dirPath; } export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl); + export const resolvePath = (path: string) => directoryName(path); export function fileExists(path: string): boolean { let response = Http.getFileFromServerSync(serverRoot + path); @@ -660,7 +703,7 @@ module Harness { export function _listFilesImpl(path: string, spec?: RegExp, options?: any) { let response = Http.getFileFromServerSync(serverRoot + path); if (response.status === 200) { - let results = response.responseText.split(','); + let results = response.responseText.split(","); if (spec) { return results.filter(file => spec.test(file)); } else { @@ -668,12 +711,12 @@ module Harness { } } else { - return ['']; + return [""]; } }; export let listFiles = Utils.memoize(_listFilesImpl); - export let log = console.log; + export let log = (s: string) => console.log(s); export function readFile(file: string) { let response = Http.getFileFromServerSync(serverRoot + file); @@ -685,12 +728,11 @@ module Harness { } export function writeFile(path: string, contents: string) { - Http.writeToServerSync(serverRoot + path, 'WRITE', contents); + Http.writeToServerSync(serverRoot + path, "WRITE", contents); } } } - export var IO: IO; switch (Utils.getExecutionEnvironment()) { case Utils.ExecutionEnvironment.CScript: IO = IOImpl.CScript; @@ -722,7 +764,7 @@ module Harness { tcServicesFileName = "built/local/typescriptServices.js"; break; default: - throw new Error('Unknown context'); + throw new Error("Unknown context"); } export let tcServicesFile = IO.readFile(tcServicesFileName); @@ -745,12 +787,12 @@ module Harness { public Write(str: string) { // out of memory usage concerns avoid using + or += if we're going to do any manipulation of this string later - this.currentLine = [(this.currentLine || ''), str].join(''); + this.currentLine = [(this.currentLine || ""), str].join(""); } public WriteLine(str: string) { // out of memory usage concerns avoid using + or += if we're going to do any manipulation of this string later - this.lines.push([(this.currentLine || ''), str].join('')); + this.lines.push([(this.currentLine || ""), str].join("")); this.currentLine = undefined; } @@ -799,7 +841,7 @@ module Harness { if (this.fileCollection.hasOwnProperty(p)) { let current = this.fileCollection[p]; if (current.lines.length > 0) { - if (p.indexOf('.d.ts') !== -1) { current.lines.unshift(['////[', Path.getFileName(p), ']'].join('')); } + if (p.indexOf(".d.ts") !== -1) { current.lines.unshift(["////[", Path.getFileName(p), "]"].join("")); } result.push({ fileName: p, file: this.fileCollection[p] }); } } @@ -828,16 +870,16 @@ module Harness { const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; - export let defaultLibFileName = 'lib.d.ts'; - export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); - export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultLibFileName = "lib.d.ts"; + export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.es6.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); // Cache these between executions so we don't have to re-parse them for every test - export let fourslashFileName = 'fourslash.ts'; + export let fourslashFileName = "fourslash.ts"; export let fourslashSourceFile: ts.SourceFile; export function getCanonicalFileName(fileName: string): string { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return Harness.IO.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase(); } export function createCompilerHost( @@ -855,7 +897,7 @@ module Harness { } let filemap: { [fileName: string]: ts.SourceFile; } = {}; - let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; + let getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory; // Register input files function register(file: { unitName: string; content: string; }) { @@ -865,41 +907,45 @@ module Harness { } }; inputFiles.forEach(register); + + function getSourceFile(fn: string, languageVersion: ts.ScriptTarget) { + fn = ts.normalizePath(fn); + if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { + return filemap[getCanonicalFileName(fn)]; + } + else if (currentDirectory) { + let canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory)); + return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined; + } + else if (fn === fourslashFileName) { + let tsFn = "tests/cases/fourslash/" + fourslashFileName; + fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); + return fourslashSourceFile; + } + else { + if (fn === defaultLibFileName) { + return languageVersion === ts.ScriptTarget.ES6 ? defaultES6LibSourceFile : defaultLibSourceFile; + } + // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC + return undefined; + } + } let newLine = newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed : newLineKind === ts.NewLineKind.LineFeed ? lineFeed : - ts.sys.newLine; + Harness.IO.newLine(); return { getCurrentDirectory, - getSourceFile: (fn, languageVersion) => { - fn = ts.normalizePath(fn); - if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { - return filemap[getCanonicalFileName(fn)]; - } - else if (currentDirectory) { - let canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory)); - return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined; - } - else if (fn === fourslashFileName) { - let tsFn = 'tests/cases/fourslash/' + fourslashFileName; - fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); - return fourslashSourceFile; - } - else { - if (fn === defaultLibFileName) { - return languageVersion === ts.ScriptTarget.ES6 ? defaultES6LibSourceFile : defaultLibSourceFile; - } - // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC - return undefined; - } - }, + getSourceFile, getDefaultLibFileName: options => defaultLibFileName, writeFile, getCanonicalFileName, useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, - getNewLine: () => newLine + getNewLine: () => newLine, + fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined, + readFile: (fileName: string): string => { throw new Error("NotYetImplemented"); } }; } @@ -974,14 +1020,14 @@ module Harness { settingsCallback(null); } - let newLine = '\r\n'; + let newLine = "\r\n"; options.skipDefaultLibCheck = true; // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. let includeBuiltFiles: { unitName: string; content: string }[] = []; - let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; + let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames(); this.settings.forEach(setCompilerOptionForSetting); let fileOutputs: GeneratedFile[] = []; @@ -999,11 +1045,9 @@ module Harness { let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); this.lastErrors = errors; - let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); onComplete(result, program); - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; return options; function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { @@ -1011,172 +1055,196 @@ module Harness { // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" case "module": case "modulegentarget": - if (typeof setting.value === 'string') { - if (setting.value.toLowerCase() === 'amd') { + if (typeof setting.value === "string") { + if (setting.value.toLowerCase() === "amd") { options.module = ts.ModuleKind.AMD; - } else if (setting.value.toLowerCase() === 'umd') { + } else if (setting.value.toLowerCase() === "umd") { options.module = ts.ModuleKind.UMD; - } else if (setting.value.toLowerCase() === 'commonjs') { + } else if (setting.value.toLowerCase() === "commonjs") { options.module = ts.ModuleKind.CommonJS; - } else if (setting.value.toLowerCase() === 'system') { + if (options.moduleResolution === undefined) { + // TODO: currently we have relative module names pretty much in all tests that use CommonJS module target. + // Such names could never be resolved in Node however classic resolution strategy still can handle them. + // Changing all module names to relative will be a major overhaul in code (but we'll do this anyway) so as a temporary measure + // we'll use ts.ModuleResolutionKind.Classic for CommonJS modules. + options.moduleResolution = ts.ModuleResolutionKind.Classic; + } + } else if (setting.value.toLowerCase() === "system") { options.module = ts.ModuleKind.System; - } else if (setting.value.toLowerCase() === 'unspecified') { + } else if (setting.value.toLowerCase() === "unspecified") { options.module = ts.ModuleKind.None; } else { - throw new Error('Unknown module type ' + setting.value); + throw new Error("Unknown module type " + setting.value); } } else { options.module = setting.value; } break; - + case "moduleresolution": + switch((setting.value || "").toLowerCase()) { + case "classic": + options.moduleResolution = ts.ModuleResolutionKind.Classic; + break; + case "node": + options.moduleResolution = ts.ModuleResolutionKind.NodeJs; + break; + } + break; case "target": - case 'codegentarget': - if (typeof setting.value === 'string') { - if (setting.value.toLowerCase() === 'es3') { + case "codegentarget": + if (typeof setting.value === "string") { + if (setting.value.toLowerCase() === "es3") { options.target = ts.ScriptTarget.ES3; - } else if (setting.value.toLowerCase() === 'es5') { + } else if (setting.value.toLowerCase() === "es5") { options.target = ts.ScriptTarget.ES5; - } else if (setting.value.toLowerCase() === 'es6') { + } else if (setting.value.toLowerCase() === "es6") { options.target = ts.ScriptTarget.ES6; } else { - throw new Error('Unknown compile target ' + setting.value); + throw new Error("Unknown compile target " + setting.value); } } else { options.target = setting.value; } break; - case 'experimentaldecorators': - options.experimentalDecorators = setting.value === 'true'; + case "experimentaldecorators": + options.experimentalDecorators = setting.value === "true"; break; - case 'emitdecoratormetadata': - options.emitDecoratorMetadata = setting.value === 'true'; + case "emitdecoratormetadata": + options.emitDecoratorMetadata = setting.value === "true"; break; - case 'experimentalasyncfunctions': - options.experimentalAsyncFunctions = setting.value === 'true'; + case "experimentalasyncfunctions": + options.experimentalAsyncFunctions = setting.value === "true"; break; - case 'noemithelpers': - options.noEmitHelpers = setting.value === 'true'; + case "noemithelpers": + options.noEmitHelpers = setting.value === "true"; break; - case 'noemitonerror': - options.noEmitOnError = setting.value === 'true'; + case "noemitonerror": + options.noEmitOnError = setting.value === "true"; break; - case 'noresolve': - options.noResolve = setting.value === 'true'; + case "noresolve": + options.noResolve = setting.value === "true"; break; - case 'noimplicitany': - options.noImplicitAny = setting.value === 'true'; + case "noimplicitany": + options.noImplicitAny = setting.value === "true"; break; - case 'nolib': - options.noLib = setting.value === 'true'; + case "nolib": + options.noLib = setting.value === "true"; break; - case 'out': - case 'outfileoption': + case "out": + case "outfileoption": options.out = setting.value; break; - case 'outdiroption': - case 'outdir': + case "outfile": + options.outFile = setting.value; + break; + + case "outdiroption": + case "outdir": options.outDir = setting.value; break; - case 'skipdefaultlibcheck': + case "skipdefaultlibcheck": options.skipDefaultLibCheck = setting.value === "true"; break; - case 'sourceroot': + case "sourceroot": options.sourceRoot = setting.value; break; - case 'maproot': + case "maproot": options.mapRoot = setting.value; break; - case 'sourcemap': - options.sourceMap = setting.value === 'true'; + case "sourcemap": + options.sourceMap = setting.value === "true"; break; - case 'declaration': - options.declaration = setting.value === 'true'; + case "declaration": + options.declaration = setting.value === "true"; break; - case 'newline': - if (setting.value.toLowerCase() === 'crlf') { + case "newline": + if (setting.value.toLowerCase() === "crlf") { options.newLine = ts.NewLineKind.CarriageReturnLineFeed; } - else if (setting.value.toLowerCase() === 'lf') { + else if (setting.value.toLowerCase() === "lf") { options.newLine = ts.NewLineKind.LineFeed; } else { - throw new Error('Unknown option for newLine: ' + setting.value); + throw new Error("Unknown option for newLine: " + setting.value); } break; - case 'comments': - options.removeComments = setting.value === 'false'; + case "comments": + options.removeComments = setting.value === "false"; break; - case 'stripinternal': - options.stripInternal = setting.value === 'true'; + case "stripinternal": + options.stripInternal = setting.value === "true"; - case 'usecasesensitivefilenames': - useCaseSensitiveFileNames = setting.value === 'true'; + case "usecasesensitivefilenames": + useCaseSensitiveFileNames = setting.value === "true"; break; - case 'filename': + case "filename": // Not supported yet break; - case 'emitbom': - options.emitBOM = setting.value === 'true'; + case "emitbom": + options.emitBOM = setting.value === "true"; break; - case 'errortruncation': - options.noErrorTruncation = setting.value === 'false'; + case "errortruncation": + options.noErrorTruncation = setting.value === "false"; break; - case 'preserveconstenums': - options.preserveConstEnums = setting.value === 'true'; + case "preserveconstenums": + options.preserveConstEnums = setting.value === "true"; break; - case 'isolatedmodules': - options.isolatedModules = setting.value === 'true'; + case "isolatedmodules": + options.isolatedModules = setting.value === "true"; break; - case 'suppressimplicitanyindexerrors': - options.suppressImplicitAnyIndexErrors = setting.value === 'true'; + case "suppressexcesspropertyerrors": + options.suppressExcessPropertyErrors = setting.value === "true"; break; - case 'includebuiltfile': + case "suppressimplicitanyindexerrors": + options.suppressImplicitAnyIndexErrors = setting.value === "true"; + break; + + case "includebuiltfile": let builtFileName = libFolder + setting.value; includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); break; - case 'inlinesourcemap': - options.inlineSourceMap = setting.value === 'true'; + case "inlinesourcemap": + options.inlineSourceMap = setting.value === "true"; break; - case 'inlinesources': - options.inlineSources = setting.value === 'true'; + case "inlinesources": + options.inlineSources = setting.value === "true"; break; - case 'jsx': - options.jsx = setting.value.toLowerCase() === 'react' ? ts.JsxEmit.React : - setting.value.toLowerCase() === 'preserve' ? ts.JsxEmit.Preserve : + case "jsx": + options.jsx = setting.value.toLowerCase() === "react" ? ts.JsxEmit.React : + setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : ts.JsxEmit.None; break; default: - throw new Error('Unsupported compiler setting ' + setting.flag); + throw new Error("Unsupported compiler setting " + setting.flag); } } } @@ -1189,7 +1257,7 @@ module Harness { // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file currentDirectory?: string) { if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { - throw new Error('There were no errors and declFiles generated did not match number of js files generated'); + throw new Error("There were no errors and declFiles generated did not match number of js files generated"); } let declInputFiles: { unitName: string; content: string }[] = []; @@ -1222,7 +1290,8 @@ module Harness { assert(sourceFile, "Program has no source file with name '" + fileName + "'"); // Is this file going to be emitted separately let sourceFileName: string; - if (ts.isExternalModule(sourceFile) || !options.out) { + let outFile = options.outFile || options.out; + if (ts.isExternalModule(sourceFile) || !outFile) { if (options.outDir) { let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); @@ -1234,7 +1303,7 @@ module Harness { } else { // Goes to single --out file - sourceFileName = options.out; + sourceFileName = outFile; } let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; @@ -1250,8 +1319,8 @@ module Harness { } function normalizeLineEndings(text: string, lineEnding: string): string { - let normalized = text.replace(/\r\n?/g, '\n'); - if (lineEnding !== '\n') { + let normalized = text.replace(/\r\n?/g, "\n"); + if (lineEnding !== "\n") { normalized = normalized.replace(/\n/g, lineEnding); } return normalized; @@ -1266,7 +1335,7 @@ module Harness { errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): "; } - errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()) + Harness.IO.newLine(); }); return errorOutput; @@ -1275,20 +1344,27 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) { diagnostics.sort(ts.compareDiagnostics); let outputLines: string[] = []; - // Count up all the errors we find so we don't miss any - let totalErrorsReported = 0; + // Count up all errors that were found in files other than lib.d.ts so we don't miss any + let totalErrorsReportedInNonLibraryFiles = 0; function outputErrorText(error: ts.Diagnostic) { - let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine); + let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()); let errLines = RunnerBase.removeFullPaths(message) - .split('\n') - .map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s) + .split("\n") + .map(s => s.length > 0 && s.charAt(s.length - 1) === "\r" ? s.substr(0, s.length - 1) : s) .filter(s => s.length > 0) - .map(s => '!!! ' + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); + .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines.push(e)); - - totalErrorsReported++; + + // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics + // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) + // then they will be added twice thus triggering 'total errors' assertion with condition + // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length + + if (!error.file || !isLibraryFile(error.file.fileName)) { + totalErrorsReportedInNonLibraryFiles++; + } } // Report global errors @@ -1305,7 +1381,7 @@ module Harness { // Header - outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ===='); + outputLines.push("==== " + inputFile.unitName + " (" + fileErrors.length + " errors) ===="); // Make sure we emit something for every error let markedErrorCount = 0; @@ -1314,13 +1390,13 @@ module Harness { // we have to string-based splitting instead and try to figure out the delimiting chars let lineStarts = ts.computeLineStarts(inputFile.content); - let lines = inputFile.content.split('\n'); + let lines = inputFile.content.split("\n"); if (lines.length === 1) { lines = lines[0].split("\r"); } lines.forEach((line, lineIndex) => { - if (line.length > 0 && line.charAt(line.length - 1) === '\r') { + if (line.length > 0 && line.charAt(line.length - 1) === "\r") { line = line.substr(0, line.length - 1); } @@ -1333,7 +1409,7 @@ module Harness { nextLineStart = lineStarts[lineIndex + 1]; } // Emit this line from the original file - outputLines.push(' ' + line); + outputLines.push(" " + line); fileErrors.forEach(err => { // Does any error start or continue on to this line? Emit squiggles let end = ts.textSpanEnd(err); @@ -1345,7 +1421,7 @@ module Harness { // Calculate the start of the squiggle let squiggleStart = Math.max(0, relativeOffset); // TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another - outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~')); + outputLines.push(" " + line.substr(0, squiggleStart).replace(/[^\s]/g, " ") + new Array(Math.min(length, line.length - squiggleStart) + 1).join("~")); // If the error ended here, or we're at the end of the file, emit its message if ((lineIndex === lines.length - 1) || nextLineStart > end) { @@ -1360,7 +1436,7 @@ module Harness { }); // Verify we didn't miss any errors in this file - assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName); + assert.equal(markedErrorCount, fileErrors.length, "count of errors in " + inputFile.unitName); }); let numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { @@ -1373,10 +1449,10 @@ module Harness { }); // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, 'total number of errors'); + assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); return minimalDiagnosticsToString(diagnostics) + - ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n'); + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { @@ -1384,15 +1460,15 @@ module Harness { outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); // Emit them - let result = ''; + let result = ""; for (let outputFile of outputFiles) { // Some extra spacing if this isn't the first file if (result.length) { - result += '\r\n\r\n'; + result += "\r\n\r\n"; } // FileName header + content - result += '/*====== ' + outputFile.fileName + ' ======*/\r\n'; + result += "/*====== " + outputFile.fileName + " ======*/\r\n"; result += outputFile.code; } @@ -1400,7 +1476,7 @@ module Harness { return result; function cleanName(fn: string) { - let lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); + let lastSlash = ts.normalizeSlashes(fn).lastIndexOf("/"); return fn.substr(lastSlash + 1).toLowerCase(); } } @@ -1418,7 +1494,7 @@ module Harness { // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' - throw new Error('compileString NYI'); + throw new Error("compileString NYI"); } export interface GeneratedFile { @@ -1432,26 +1508,26 @@ module Harness { } export function isTS(fileName: string) { - return stringEndsWith(fileName, '.ts'); + return stringEndsWith(fileName, ".ts"); } export function isTSX(fileName: string) { - return stringEndsWith(fileName, '.tsx'); + return stringEndsWith(fileName, ".tsx"); } export function isDTS(fileName: string) { - return stringEndsWith(fileName, '.d.ts'); + return stringEndsWith(fileName, ".d.ts"); } export function isJS(fileName: string) { - return stringEndsWith(fileName, '.js'); + return stringEndsWith(fileName, ".js"); } export function isJSX(fileName: string) { - return stringEndsWith(fileName, '.jsx'); + return stringEndsWith(fileName, ".jsx"); } export function isJSMap(fileName: string) { - return stringEndsWith(fileName, '.js.map'); + return stringEndsWith(fileName, ".js.map") || stringEndsWith(fileName, ".jsx.map"); } /** Contains the code and errors of a compilation and some helper methods to check its status. */ @@ -1478,7 +1554,7 @@ module Harness { this.sourceMaps.push(emittedFile); } else { - throw new Error('Unrecognized file extension for file ' + emittedFile.fileName); + throw new Error("Unrecognized file extension for file " + emittedFile.fileName); } }); @@ -1517,7 +1593,7 @@ module Harness { "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", + "includebuiltfile", "suppressexcesspropertyerrors", "suppressimplicitanyindexerrors", "stripinternal", "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", "inlinesources", "emitdecoratormetadata", "experimentaldecorators", "skipdefaultlibcheck", "jsx"]; @@ -1587,10 +1663,10 @@ module Harness { // Subfile content line // Append to the current subfile content, inserting a newline needed if (currentFileContent === null) { - currentFileContent = ''; + currentFileContent = ""; } else { // End-of-line - currentFileContent = currentFileContent + '\n'; + currentFileContent = currentFileContent + "\n"; } currentFileContent = currentFileContent + line; } @@ -1601,7 +1677,7 @@ module Harness { // EOF, push whatever remains let newTestFile2 = { - content: currentFileContent || '', + content: currentFileContent || "", name: currentFileName, fileOptions: currentFileOptions, originalFilePath: fileName, @@ -1623,27 +1699,27 @@ module Harness { export function localPath(fileName: string, baselineFolder?: string, subfolder?: string) { if (baselineFolder === undefined) { - return baselinePath(fileName, 'local', 'tests/baselines', subfolder); + return baselinePath(fileName, "local", "tests/baselines", subfolder); } else { - return baselinePath(fileName, 'local', baselineFolder, subfolder); + return baselinePath(fileName, "local", baselineFolder, subfolder); } } function referencePath(fileName: string, baselineFolder?: string, subfolder?: string) { if (baselineFolder === undefined) { - return baselinePath(fileName, 'reference', 'tests/baselines', subfolder); + return baselinePath(fileName, "reference", "tests/baselines", subfolder); } else { - return baselinePath(fileName, 'reference', baselineFolder, subfolder); + return baselinePath(fileName, "reference", baselineFolder, subfolder); } } function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { - return Harness.userSpecifiedRoot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName; } else { - return Harness.userSpecifiedRoot + baselineFolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName; } } @@ -1677,7 +1753,7 @@ module Harness { let actual = generateContent(); if (actual === undefined) { - throw new Error('The generated content was "undefined". Return "null" if no baselining is required."'); + throw new Error("The generated content was \"undefined\". Return \"null\" if no baselining is required.\""); } // Store the content in the 'local' folder so we @@ -1700,10 +1776,10 @@ module Harness { let refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); if (actual === null) { - actual = ''; + actual = ""; } - let expected = ''; + let expected = ""; if (IO.fileExists(refFileName)) { expected = IO.readFile(refFileName); } @@ -1712,10 +1788,10 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { - let encoded_actual = (new Buffer(actual)).toString('utf8'); + let encoded_actual = Utils.encodeString(actual); if (expected != encoded_actual) { // Overwrite & issue error - let errMsg = 'The baseline file ' + relativeFileName + ' has changed'; + let errMsg = "The baseline file " + relativeFileName + " has changed"; throw new Error(errMsg); } } @@ -1744,18 +1820,18 @@ module Harness { } export function isLibraryFile(filePath: string): boolean { - return (Path.getFileName(filePath) === 'lib.d.ts') || (Path.getFileName(filePath) === 'lib.core.d.ts'); + return (Path.getFileName(filePath) === "lib.d.ts") || (Path.getFileName(filePath) === "lib.core.d.ts"); } export function isBuiltFile(filePath: string): boolean { return filePath.indexOf(Harness.libFolder) === 0; } - export function getDefaultLibraryFile(): { unitName: string, content: string } { - let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; + export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } { + let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts"; return { unitName: libFile, - content: IO.readFile(libFile) + content: io.readFile(libFile) }; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 3c543e50566..f228bc862d8 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -1,7 +1,7 @@ -/// -/// -/// -/// +/// +/// +/// +/// module Harness.LanguageService { export class ScriptInfo { @@ -203,9 +203,35 @@ module Harness.LanguageService { /// Shim adapter class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { + + public getModuleResolutionsForFile: (fileName: string)=> string; + + constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options); + + if (preprocessToResolve) { + let compilerOptions = this.nativeHost.getCompilationSettings() + let moduleResolutionHost: ts.ModuleResolutionHost = { + fileExists: fileName => this.getScriptInfo(fileName) !== undefined, + readFile: fileName => { + let scriptInfo = this.getScriptInfo(fileName); + return scriptInfo && scriptInfo.content; + } + }; + this.getModuleResolutionsForFile = (fileName) => { + let scriptInfo = this.getScriptInfo(fileName); + let preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); + let imports: ts.Map = {}; + for (let module of preprocessInfo.importedFiles) { + let resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); + if (resolutionInfo.resolvedFileName) { + imports[module.fileName] = resolutionInfo.resolvedFileName; + } + } + return JSON.stringify(imports); + } + } } getFilenames(): string[] { return this.nativeHost.getFilenames(); } @@ -229,7 +255,11 @@ module Harness.LanguageService { readDirectory(rootDir: string, extension: string): string { throw new Error("NYI"); } - + fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } + readFile(fileName: string) { + let snapshot = this.nativeHost.getScriptSnapshot(fileName); + return snapshot && snapshot.getText(0, snapshot.getLength()); + } log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } @@ -242,7 +272,7 @@ module Harness.LanguageService { throw new Error("NYI"); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { - let result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n'); + let result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n"); let entries: ts.ClassificationInfo[] = []; let i = 0; let position = 0; @@ -381,6 +411,9 @@ module Harness.LanguageService { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: ts.FormatCodeOptions): ts.TextChange[] { return unwrapJSONCallResult(this.shim.getFormattingEditsAfterKeystroke(fileName, position, key, JSON.stringify(options))); } + getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion { + return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); + } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); } @@ -396,8 +429,8 @@ module Harness.LanguageService { export class ShimLanugageServiceAdapter implements LanguageServiceAdapter { private host: ShimLanguageServiceHost; private factory: ts.TypeScriptServicesFactory; - constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { - this.host = new ShimLanguageServiceHost(cancellationToken, options); + constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { + this.host = new ShimLanguageServiceHost(preprocessToResolve, cancellationToken, options); this.factory = new TypeScript.Services.TypeScriptServicesFactory(); } getHost() { return this.host; } @@ -416,6 +449,7 @@ module Harness.LanguageService { let convertResult: ts.PreProcessedFileInfo = { referencedFiles: [], importedFiles: [], + ambientExternalModules: [], isLibFile: shimResult.isLibFile }; diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index c7b57a7d51f..5a572e220b3 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -73,7 +73,7 @@ interface PlaybackControl { module Playback { let recordLog: IOLog = undefined; let replayLog: IOLog = undefined; - let recordLogFileNameBase = ''; + let recordLogFileNameBase = ""; interface Memoized { (s: string): T; @@ -93,13 +93,13 @@ module Playback { return run; } - export interface PlaybackSystem extends ts.System, PlaybackControl { } + export interface PlaybackIO extends Harness.IO, PlaybackControl { } function createEmptyLog(): IOLog { return { timestamp: (new Date()).toString(), arguments: [], - currentDirectory: '', + currentDirectory: "", filesRead: [], filesWritten: [], filesDeleted: [], @@ -110,7 +110,7 @@ module Playback { dirExists: [], dirsCreated: [], pathsResolved: [], - executingPath: '' + executingPath: "" }; } @@ -170,7 +170,7 @@ module Playback { if (defaultValue !== undefined) { return defaultValue; } else { - throw new Error('No matching result in log array for: ' + JSON.stringify(expectedFields)); + throw new Error("No matching result in log array for: " + JSON.stringify(expectedFields)); } } return results[0].result; @@ -195,7 +195,7 @@ module Playback { } // If we got here, we didn't find a match if (defaultValue === undefined) { - throw new Error('No matching result in log array for path: ' + expectedPath); + throw new Error("No matching result in log array for path: " + expectedPath); } else { return defaultValue; } @@ -203,7 +203,7 @@ module Playback { let pathEquivCache: any = {}; function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) { - let key = left + '-~~-' + right; + let key = left + "-~~-" + right; function areSame(a: string, b: string) { return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase(); } @@ -223,8 +223,8 @@ module Playback { // console.log("Swallowed write operation during replay: " + name); } - export function wrapSystem(underlying: ts.System): PlaybackSystem { - let wrapper: PlaybackSystem = {}; + export function wrapIO(underlying: Harness.IO): PlaybackIO { + let wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); wrapper.startReplayFromFile = logFn => { @@ -233,24 +233,30 @@ module Playback { wrapper.endRecord = () => { if (recordLog !== undefined) { let i = 0; - let fn = () => recordLogFileNameBase + i + '.json'; + let fn = () => recordLogFileNameBase + i + ".json"; while (underlying.fileExists(fn())) i++; underlying.writeFile(fn(), JSON.stringify(recordLog)); recordLog = undefined; } }; - - Object.defineProperty(wrapper, 'args', { - get() { - if (replayLog !== undefined) { - return replayLog.arguments; - } else if (recordLog !== undefined) { - recordLog.arguments = underlying.args; - } - return underlying.args; + + wrapper.args = () => { + if (replayLog !== undefined) { + return replayLog.arguments; + } else if (recordLog !== undefined) { + recordLog.arguments = underlying.args(); } - }); - + return underlying.args(); + } + + wrapper.newLine = () => underlying.newLine(); + wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames(); + wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; + wrapper.createDirectory = path => { throw new Error("NotSupported"); }; + wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; + wrapper.deleteFile = path => { throw new Error("NotSupported"); }; + wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; + wrapper.log = text => underlying.log(text); wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( (path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }), @@ -276,7 +282,7 @@ module Playback { wrapper.getCurrentDirectory = () => { if (replayLog !== undefined) { - return replayLog.currentDirectory || ''; + return replayLog.currentDirectory || ""; } else if (recordLog !== undefined) { return recordLog.currentDirectory = underlying.getCurrentDirectory(); } else { @@ -286,7 +292,7 @@ module Playback { wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( (path) => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path: path }), - memoize((path) => findResultByFields(replayLog.pathsResolved, { path: path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + '/' + path : ts.normalizeSlashes(path)))); + memoize((path) => findResultByFields(replayLog.pathsResolved, { path: path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); wrapper.readFile = recordReplay(wrapper.readFile, underlying)( (path) => { @@ -299,7 +305,7 @@ module Playback { wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path: path, contents: contents, bom: false }), - (path, contents) => noOpReplay('writeFile')); + (path, contents) => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 5ea118aacbf..fe4ab8ea8ea 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -62,7 +62,7 @@ class ProjectRunner extends RunnerBase { let testFileText: string = null; try { - testFileText = ts.sys.readFile(testCaseFileName); + testFileText = Harness.IO.readFile(testCaseFileName); } catch (e) { assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message); @@ -74,7 +74,7 @@ class ProjectRunner extends RunnerBase { catch (e) { assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message); } - let testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, ""); + let testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, "").replace(/\.json/, ""); function moduleNameToString(moduleKind: ts.ModuleKind) { return moduleKind === ts.ModuleKind.AMD @@ -98,7 +98,7 @@ class ProjectRunner extends RunnerBase { } function cleanProjectUrl(url: string) { - let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot)); + let diskProjectPath = ts.normalizeSlashes(Harness.IO.resolvePath(testCase.projectRoot)); let projectRootUrl = "file:///" + diskProjectPath; let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot); diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot)); @@ -122,7 +122,7 @@ class ProjectRunner extends RunnerBase { } function getCurrentDirectory() { - return ts.sys.resolvePath(testCase.projectRoot); + return Harness.IO.resolvePath(testCase.projectRoot); } function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[], @@ -158,11 +158,12 @@ class ProjectRunner extends RunnerBase { return { declaration: !!testCase.declaration, sourceMap: !!testCase.sourceMap, - out: testCase.out, + outFile: testCase.out, outDir: testCase.outDir, - mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot, - sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, + mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot, + sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, module: moduleKind, + moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future noResolve: testCase.noResolve, rootDir: testCase.rootDir }; @@ -190,8 +191,10 @@ class ProjectRunner extends RunnerBase { writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, - useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, - getNewLine: () => ts.sys.newLine + useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(), + getNewLine: () => Harness.IO.newLine(), + fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined, + readFile: fileName => Harness.IO.readFile(fileName) }; } } @@ -214,7 +217,7 @@ class ProjectRunner extends RunnerBase { function getSourceFileText(fileName: string): string { let text: string = undefined; try { - text = ts.sys.readFile(ts.isRootedDiskPath(fileName) + text = Harness.IO.readFile(ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); } @@ -261,14 +264,14 @@ class ProjectRunner extends RunnerBase { // Actual writing of file as in tc.ts function ensureDirectoryStructure(directoryname: string) { if (directoryname) { - if (!ts.sys.directoryExists(directoryname)) { + if (!Harness.IO.directoryExists(directoryname)) { ensureDirectoryStructure(ts.getDirectoryPath(directoryname)); - ts.sys.createDirectory(directoryname); + Harness.IO.createDirectory(directoryname); } } } ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath))); - ts.sys.writeFile(outputFilePath, data, writeByteOrderMark); + Harness.IO.writeFile(outputFilePath, data); outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark }); } @@ -297,7 +300,7 @@ class ProjectRunner extends RunnerBase { allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName)); } else { - let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile|| compilerOptions.out) + ".d.ts"; let outputDtsFile = findOutpuDtsFile(outputDtsFileName); if (!ts.contains(allInputFiles, outputDtsFile)) { allInputFiles.unshift(outputDtsFile); @@ -331,9 +334,9 @@ class ProjectRunner extends RunnerBase { return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors); } - let name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName; + let name = "Compiling project for " + testCase.scenario + ": testcase " + testCaseFileName; - describe('Projects tests', () => { + describe("Projects tests", () => { describe(name, () => { function verifyCompilerResults(moduleKind: ts.ModuleKind) { let compilerResult: BatchCompileProjectTestCaseResult; @@ -367,29 +370,29 @@ class ProjectRunner extends RunnerBase { compilerResult = batchCompilerProjectTestCase(moduleKind); }); - it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => { + it("Resolution information of (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { + Harness.Baseline.runBaseline("Resolution information of (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => { return JSON.stringify(getCompilerResolutionInfo(), undefined, " "); }); }); - it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + it("Errors for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (compilerResult.errors.length) { - Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => { + Harness.Baseline.runBaseline("Errors for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => { return getErrorsBaseline(compilerResult); }); } }); - it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (testCase.baselineCheck) { ts.forEach(compilerResult.outputFiles, outputFile => { - Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { + Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { try { - return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); + return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); } catch (e) { return undefined; @@ -400,9 +403,9 @@ class ProjectRunner extends RunnerBase { }); - it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (compilerResult.sourceMapData) { - Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => { + Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => { return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program, ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName))); }); @@ -411,11 +414,11 @@ class ProjectRunner extends RunnerBase { // Verify that all the generated .d.ts files compile - it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + it("Errors in generated Dts files for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (!compilerResult.errors.length && testCase.declaration) { let dTsCompileResult = compileCompileDTsFiles(compilerResult); if (dTsCompileResult.errors.length) { - Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => { + Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => { return getErrorsBaseline(dTsCompileResult); }); } diff --git a/src/harness/runner.ts b/src/harness/runner.ts index e4ed604e980..822fcdebe8c 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -13,12 +13,12 @@ // limitations under the License. // -/// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// +/// let runners: RunnerBase[] = []; let iterations: number = 1; @@ -32,13 +32,13 @@ function runTests(runners: RunnerBase[]) { } // users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options -let mytestconfig = 'mytest.config'; -let testconfig = 'test.config'; +let mytestconfig = "mytest.config"; +let testconfig = "test.config"; let testConfigFile = Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) : - (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ''); + (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ""); -if (testConfigFile !== '') { +if (testConfigFile !== "") { let testConfig = JSON.parse(testConfigFile); if (testConfig.light) { Harness.lightMode = true; @@ -51,33 +51,36 @@ if (testConfigFile !== '') { } switch (option) { - case 'compiler': + case "compiler": runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); runners.push(new ProjectRunner()); break; - case 'conformance': + case "conformance": runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); break; - case 'project': + case "project": runners.push(new ProjectRunner()); break; - case 'fourslash': + case "fourslash": runners.push(new FourSlashRunner(FourSlashTestType.Native)); break; - case 'fourslash-shims': + case "fourslash-shims": runners.push(new FourSlashRunner(FourSlashTestType.Shims)); break; + case 'fourslash-shims-pp': + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); + break; case 'fourslash-server': runners.push(new FourSlashRunner(FourSlashTestType.Server)); break; - case 'fourslash-generated': + case "fourslash-generated": runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); break; - case 'rwc': + case "rwc": runners.push(new RWCRunner()); break; - case 'test262': + case "test262": runners.push(new Test262BaselineRunner()); break; } @@ -98,10 +101,9 @@ if (runners.length === 0) { // language services runners.push(new FourSlashRunner(FourSlashTestType.Native)); runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); runners.push(new FourSlashRunner(FourSlashTestType.Server)); // runners.push(new GeneratedFourslashRunner()); } -ts.sys.newLine = '\r\n'; - runTests(runners); diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 406ca7caeae..afe757ea829 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -33,7 +33,7 @@ abstract class RunnerBase { // when running in the browser the 'full path' is the host name, shows up in error baselines let localHost = /http:\/localhost:\d+/g; - fixedPath = fixedPath.replace(localHost, ''); + fixedPath = fixedPath.replace(localHost, ""); return fixedPath; } } \ No newline at end of file diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 54aeff18efd..a1aaeed3d55 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -1,21 +1,21 @@ -/// -/// -/// -/// +/// +/// +/// +/// module RWC { - function runWithIOLog(ioLog: IOLog, fn: () => void) { - let oldSys = ts.sys; + function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) { + let oldIO = Harness.IO; - let wrappedSys = Playback.wrapSystem(ts.sys); - wrappedSys.startReplayFromData(ioLog); - ts.sys = wrappedSys; + let wrappedIO = Playback.wrapIO(oldIO); + wrappedIO.startReplayFromData(ioLog); + Harness.IO = wrappedIO; try { - fn(); + fn(oldIO); } finally { - wrappedSys.endReplay(); - ts.sys = oldSys; + wrappedIO.endReplay(); + Harness.IO = oldIO; } } @@ -26,13 +26,12 @@ module RWC { let compilerResult: Harness.Compiler.CompilerResult; let compilerOptions: ts.CompilerOptions; let baselineOpts: Harness.Baseline.BaselineOptions = { - Subfolder: 'rwc', - Baselinefolder: 'internal/baselines' + Subfolder: "rwc", + Baselinefolder: "internal/baselines" }; let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; let currentDirectory: string; let useCustomLibraryFile: boolean; - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -49,7 +48,7 @@ module RWC { useCustomLibraryFile = undefined; }); - it('can compile', () => { + it("can compile", () => { let harnessCompiler = Harness.Compiler.getCompiler(); let opts: ts.ParsedCommandLine; @@ -57,7 +56,7 @@ module RWC { currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); + opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName)); assert.equal(opts.errors.length, 0); // To provide test coverage of output javascript file, @@ -65,7 +64,7 @@ module RWC { opts.options.noEmitOnError = false; }); - runWithIOLog(ioLog, () => { + runWithIOLog(ioLog, oldIO => { harnessCompiler.reset(); // Load the files @@ -74,10 +73,11 @@ module RWC { }); // Add files to compilation + let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath; for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. - var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); - let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); + const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); + let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath)); if (!Harness.isLibraryFile(fileRead.path)) { if (inInputList) { @@ -96,7 +96,8 @@ module RWC { inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else { - inputFiles.push(Harness.getDefaultLibraryFile()); + // set the flag to put default library to the beginning of the list + inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO)); } } } @@ -117,27 +118,27 @@ module RWC { }); function getHarnessCompilerInputUnit(fileName: string) { - let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)); let content: string = null; try { - content = ts.sys.readFile(unitName); + content = Harness.IO.readFile(unitName); } catch (e) { - content = ts.sys.readFile(fileName); + content = Harness.IO.readFile(fileName); } return { unitName, content }; } }); - it('has the expected emitted code', () => { - Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { + it("has the expected emitted code", () => { + Harness.Baseline.runBaseline("has the expected emitted code", baseName + ".output.js", () => { return Harness.Compiler.collateOutputs(compilerResult.files); }, false, baselineOpts); }); - it('has the expected declaration file content', () => { - Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => { + it("has the expected declaration file content", () => { + Harness.Baseline.runBaseline("has the expected declaration file content", baseName + ".d.ts", () => { if (!compilerResult.declFilesCode.length) { return null; } @@ -146,8 +147,8 @@ module RWC { }, false, baselineOpts); }); - it('has the expected source maps', () => { - Harness.Baseline.runBaseline('has the expected source maps', baseName + '.map', () => { + it("has the expected source maps", () => { + Harness.Baseline.runBaseline("has the expected source maps", baseName + ".map", () => { if (!compilerResult.sourceMaps.length) { return null; } @@ -156,16 +157,16 @@ module RWC { }, false, baselineOpts); }); - /*it('has correct source map record', () => { + /*it("has correct source map record", () => { if (compilerOptions.sourceMap) { - Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => { + Harness.Baseline.runBaseline("has correct source map record", baseName + ".sourcemap.txt", () => { return compilerResult.getSourceMapRecord(); }, false, baselineOpts); } });*/ - it('has the expected errors', () => { - Harness.Baseline.runBaseline('has the expected errors', baseName + '.errors.txt', () => { + it("has the expected errors", () => { + Harness.Baseline.runBaseline("has the expected errors", baseName + ".errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } @@ -176,9 +177,9 @@ module RWC { // Ideally, a generated declaration file will have no errors. But we allow generated // declaration file errors as part of the baseline. - it('has the expected errors in generated declaration files', () => { + it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => { + Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => { let declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions, currentDirectory); if (declFileCompilationResult.declResult.errors.length === 0) { @@ -186,7 +187,7 @@ module RWC { } return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - ts.sys.newLine + ts.sys.newLine + + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, false, baselineOpts); } diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 767dd37949f..55ca9ea9651 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -13,7 +13,7 @@ // limitations under the License. // -/// +/// module Harness.SourceMapRecoder { @@ -50,11 +50,11 @@ module Harness.SourceMapRecoder { return true; } - if (sourceMapMappings.charAt(decodingIndex) == ',') { + if (sourceMapMappings.charAt(decodingIndex) == ",") { return true; } - if (sourceMapMappings.charAt(decodingIndex) == ';') { + if (sourceMapMappings.charAt(decodingIndex) == ";") { return true; } @@ -117,7 +117,7 @@ module Harness.SourceMapRecoder { } while (decodingIndex < sourceMapMappings.length) { - if (sourceMapMappings.charAt(decodingIndex) == ';') { + if (sourceMapMappings.charAt(decodingIndex) == ";") { // New line decodeOfEncodedMapping.emittedLine++; decodeOfEncodedMapping.emittedColumn = 1; @@ -125,7 +125,7 @@ module Harness.SourceMapRecoder { continue; } - if (sourceMapMappings.charAt(decodingIndex) == ',') { + if (sourceMapMappings.charAt(decodingIndex) == ",") { // Next entry is on same line - no action needed decodingIndex++; continue; @@ -459,6 +459,6 @@ module Harness.SourceMapRecoder { SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them } sourceMapRecoder.Close(); - return sourceMapRecoder.lines.join('\r\n'); + return sourceMapRecoder.lines.join("\r\n"); } } diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index e34e58844ac..d9bbd55e7a3 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -1,9 +1,9 @@ -/// -/// +/// +/// class Test262BaselineRunner extends RunnerBase { - private static basePath = 'internal/cases/test262'; - private static helpersFilePath = 'tests/cases/test262-harness/helpers.d.ts'; + private static basePath = "internal/cases/test262"; + private static helpersFilePath = "tests/cases/test262-harness/helpers.d.ts"; private static helperFile = { unitName: Test262BaselineRunner.helpersFilePath, content: Harness.IO.readFile(Test262BaselineRunner.helpersFilePath) @@ -15,8 +15,8 @@ class Test262BaselineRunner extends RunnerBase { module: ts.ModuleKind.CommonJS }; private static baselineOptions: Harness.Baseline.BaselineOptions = { - Subfolder: 'test262', - Baselinefolder: 'internal/baselines' + Subfolder: "test262", + Baselinefolder: "internal/baselines" }; private static getTestFilePath(filename: string): string { @@ -24,7 +24,7 @@ class Test262BaselineRunner extends RunnerBase { } private runTest(filePath: string) { - describe('test262 test for ' + filePath, () => { + describe("test262 test for " + filePath, () => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Everything declared here should be cleared out in the "after" callback. let testState: { @@ -36,7 +36,7 @@ class Test262BaselineRunner extends RunnerBase { before(() => { let content = Harness.IO.readFile(filePath); - let testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test"; + let testFilename = ts.removeFileExtension(filePath).replace(/\//g, "_") + ".test"; let testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename); let inputFiles = testCaseContent.testUnitData.map(unit => { @@ -61,15 +61,15 @@ class Test262BaselineRunner extends RunnerBase { testState = undefined; }); - it('has the expected emitted code', () => { - Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => { + it("has the expected emitted code", () => { + Harness.Baseline.runBaseline("has the expected emitted code", testState.filename + ".output.js", () => { let files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath); return Harness.Compiler.collateOutputs(files); }, false, Test262BaselineRunner.baselineOptions); }); - it('has the expected errors', () => { - Harness.Baseline.runBaseline('has the expected errors', testState.filename + '.errors.txt', () => { + it("has the expected errors", () => { + Harness.Baseline.runBaseline("has the expected errors", testState.filename + ".errors.txt", () => { let errors = testState.compilerResult.errors; if (errors.length === 0) { return null; @@ -79,13 +79,13 @@ class Test262BaselineRunner extends RunnerBase { }, false, Test262BaselineRunner.baselineOptions); }); - it('satisfies inletiants', () => { + it("satisfies inletiants", () => { let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); Utils.assertInvariants(sourceFile, /*parent:*/ undefined); }); - it('has the expected AST', () => { - Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt', () => { + it("has the expected AST", () => { + Harness.Baseline.runBaseline("has the expected AST", testState.filename + ".AST.txt", () => { let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); return Utils.sourceFileToJSON(sourceFile); }, false, Test262BaselineRunner.baselineOptions); diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index eab52af6bdf..ab4fcf93902 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -71,4 +71,4 @@ class TypeWriterWalker { symbol: symbolString }); } -} +} diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 442921ca5a4..7259ff5081c 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -316,31 +316,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -1182,3 +1182,2644 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; diff --git a/src/lib/dom.es6.d.ts b/src/lib/dom.es6.d.ts index 8702201bb9e..e83b8531011 100644 --- a/src/lib/dom.es6.d.ts +++ b/src/lib/dom.es6.d.ts @@ -8,4 +8,4 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator -} \ No newline at end of file +} diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 32e8fb45ce4..90075a290a4 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -2459,7 +2459,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -2916,6 +2916,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3030,7 +3031,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -3903,7 +3904,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -6865,7 +6865,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6986,7 +6986,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7016,11 +7016,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -7703,7 +7706,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -8445,7 +8448,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -11962,7 +11965,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -12169,7 +12172,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12439,7 +12442,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12595,7 +12598,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12617,12 +12620,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -12777,7 +12800,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 97291f742bd..c07d047b58e 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -87,8 +87,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -98,8 +98,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -170,16 +170,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -248,15 +251,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -408,6 +420,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -619,37 +666,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -678,6 +764,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -767,440 +857,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -1208,289 +893,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -1498,289 +925,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -1788,289 +961,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -2078,289 +997,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -2368,289 +1029,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -2658,289 +1061,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -2948,289 +1093,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -3238,289 +1125,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -3528,9 +1157,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -3555,9 +1183,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -3658,20 +1286,3 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} \ No newline at end of file diff --git a/src/lib/extensions.d.ts b/src/lib/extensions.d.ts deleted file mode 100644 index 8c67c7e826f..00000000000 --- a/src/lib/extensions.d.ts +++ /dev/null @@ -1,2305 +0,0 @@ - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} - -interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; -} - -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Int8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint8Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint16Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Int32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Uint32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float32Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): Float64Array; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor; \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 5c41869e487..9353047e9c6 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -3,10 +3,28 @@ /// IE Worker APIs ///////////////////////////// +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + interface EventListener { (evt: Event): void; } +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): any; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + interface Blob { size: number; type: string; @@ -60,6 +78,21 @@ declare var Console: { new(): Console; } +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + interface DOMError { name: string; toString(): string; @@ -210,7 +243,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -281,7 +314,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -402,7 +435,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -432,11 +465,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface MSApp { clearTemporaryWebDataAsync(): MSAppAsyncOperation; createBlobFromRandomAccessStream(type: string, seeker: any): Blob; @@ -460,6 +496,29 @@ interface MSApp { } declare var MSApp: MSApp; +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + interface MSBlobBuilder { append(data: any, endings?: string): void; getBlob(contentType?: string): Blob; @@ -496,6 +555,18 @@ declare var MSStreamReader: { new(): MSStreamReader; } +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + interface MessageChannel { port1: MessagePort; port2: MessagePort; @@ -516,7 +587,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -533,6 +604,33 @@ declare var MessagePort: { new(): MessagePort; } +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + interface ProgressEvent extends Event { lengthComputable: boolean; loaded: number; @@ -542,7 +640,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface WebSocket extends EventTarget { @@ -620,7 +718,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -642,6 +740,15 @@ declare var XMLHttpRequest: { create(): XMLHttpRequest; } +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + interface AbstractWorker { onerror: (ev: Event) => any; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -661,7 +768,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -702,7 +809,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -788,25 +895,39 @@ interface WorkerUtils extends Object, WindowBase64 { } -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { - (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -820,11 +941,11 @@ interface MediaQueryListListener { interface MSLaunchUriCallback { (): void; } -interface FrameRequestCallback { - (time: number): void; +interface MSUnsafeFunctionCallback { + (): any; } -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; } interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; diff --git a/src/server/client.ts b/src/server/client.ts index 3ad7230cf33..ae234750d88 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -183,7 +183,7 @@ namespace ts.server { return { configFileName: response.body.configFileName, - fileNameList: response.body.fileNameList + fileNames: response.body.fileNames }; } @@ -527,8 +527,33 @@ namespace ts.server { }); } - getDocumentHighlights(fileName: string, position: number): DocumentHighlights[] { - throw new Error("Not Implemented Yet."); + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] { + let { line, offset } = this.positionToOneBasedLineOffset(fileName, position); + let args: protocol.DocumentHighlightsRequestArgs = { file: fileName, line, offset, filesToSearch }; + + let request = this.processRequest(CommandNames.DocumentHighlights, args); + let response = this.processResponse(request); + + let self = this; + return response.body.map(convertToDocumentHighlights); + + function convertToDocumentHighlights(item: ts.server.protocol.DocumentHighlightsItem): ts.DocumentHighlights { + let { file, highlightSpans } = item; + + return { + fileName: file, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + + function convertHighlightSpan(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan { + let start = self.lineOffsetToPosition(file, span.start); + let end = self.lineOffsetToPosition(file, span.end); + return { + textSpan: ts.createTextSpanFromBounds(start, end), + kind: span.kind + }; + } + } } getOutliningSpans(fileName: string): OutliningSpan[] { @@ -538,6 +563,10 @@ namespace ts.server { getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { throw new Error("Not Implemented Yet."); } + + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion { + throw new Error("Not Implemented Yet."); + } getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { var lineOffset = this.positionToOneBasedLineOffset(fileName, position); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 91d400ff263..76bc586b8bb 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -78,15 +78,76 @@ namespace ts.server { return this.snap().getChangeRange(oldSnapshot); } } - + + interface TimestampedResolvedModule extends ResolvedModule { + lastCheckTime: number; + } + export class LSHost implements ts.LanguageServiceHost { ls: ts.LanguageService = null; compilationSettings: ts.CompilerOptions; filenameToScript: ts.Map = {}; roots: ScriptInfo[] = []; - + private resolvedModuleNames: ts.FileMap>; + private moduleResolutionHost: ts.ModuleResolutionHost; + constructor(public host: ServerHost, public project: Project) { + this.resolvedModuleNames = ts.createFileMap>(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)) + this.moduleResolutionHost = { + fileExists: fileName => this.fileExists(fileName), + readFile: fileName => this.host.readFile(fileName) + } } + + resolveModuleNames(moduleNames: string[], containingFile: string): string[] { + let currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + + let newResolutions: Map = {}; + let resolvedFileNames: string[] = []; + + let compilerOptions = this.getCompilationSettings(); + + for (let moduleName of moduleNames) { + // check if this is a duplicate entry in the list + let resolution = lookUp(newResolutions, moduleName); + if (!resolution) { + let existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); + if (moduleResolutionIsValid(existingResolution)) { + // ok, it is safe to use existing module resolution results + resolution = existingResolution; + } + else { + resolution = resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); + resolution.lastCheckTime = Date.now(); + newResolutions[moduleName] = resolution; + } + } + + ts.Debug.assert(resolution !== undefined); + + resolvedFileNames.push(resolution.resolvedFileName); + } + + // replace old results with a new one + this.resolvedModuleNames.set(containingFile, newResolutions); + return resolvedFileNames; + + function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean { + if (!resolution) { + return false; + } + + if (resolution.resolvedFileName) { + // TODO: consider checking failedLookupLocations + // TODO: use lastCheckTime to track expiration for module name resolution + return true; + } + + // consider situation if we have no candidate locations as valid resolution. + // after all there is no point to invalidate it if we have no idea where to look for the module. + return resolution.failedLookupLocations.length === 0; + } + } getDefaultLibFileName() { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); @@ -102,6 +163,8 @@ namespace ts.server { setCompilationSettings(opt: ts.CompilerOptions) { this.compilationSettings = opt; + // conservatively assume that changing compiler options might affect module resolution strategy + this.resolvedModuleNames.clear(); } lineAffectsRefs(filename: string, line: number) { @@ -137,6 +200,7 @@ namespace ts.server { removeReferencedFile(info: ScriptInfo) { if (!info.isOpen) { this.filenameToScript[info.fileName] = undefined; + this.resolvedModuleNames.remove(info.fileName); } } @@ -160,6 +224,14 @@ namespace ts.server { this.roots.push(info); } } + + removeRoot(info: ScriptInfo) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + } saveTo(filename: string, tmpfilename: string) { var script = this.getScriptInfo(filename); @@ -281,6 +353,7 @@ namespace ts.server { export class Project { compilerService: CompilerService; projectFilename: string; + projectFileWatcher: FileWatcher; program: ts.Program; filenameToSourceFile: ts.Map = {}; updateGraphSeq = 0; @@ -288,7 +361,7 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { - this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions); + this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } addOpenRef() { @@ -304,7 +377,7 @@ namespace ts.server { return this.projectService.openFile(filename, false); } - getFileNameList() { + getFileNames() { let sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(sourceFile => sourceFile.fileName); } @@ -359,6 +432,12 @@ namespace ts.server { info.defaultProject = this; this.compilerService.host.addRoot(info); } + + // remove a root file from project + removeRoot(info: ScriptInfo) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + } filesToString() { var strBuilder = ""; @@ -453,6 +532,12 @@ namespace ts.server { } } + watchedProjectConfigFileChanged(project: Project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + } + log(msg: string, type = "Err") { this.psLogger.msg(msg, type); } @@ -530,16 +615,29 @@ namespace ts.server { this.configuredProjects = configuredProjects; } + removeConfiguredProject(project: Project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + + let fileNames = project.getFileNames(); + for (let fileName of fileNames) { + let info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + } + setConfiguredProjectRoot(info: ScriptInfo) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - let configuredProject = this.configuredProjects[i]; - if (configuredProject.isRoot(info)) { - info.defaultProject = configuredProject; - configuredProject.addOpenRef(); - return true; - } - } - return false; + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + let configuredProject = this.configuredProjects[i]; + if (configuredProject.isRoot(info)) { + info.defaultProject = configuredProject; + configuredProject.addOpenRef(); + return true; + } + } + return false; } addOpenFile(info: ScriptInfo) { @@ -583,7 +681,6 @@ namespace ts.server { /** * Remove this file from the set of open, non-configured files. * @param info The file that has been closed or newly configured - * @param openedByConfig True if info has become a root of a configured project */ closeOpenFile(info: ScriptInfo) { var openFileRoots: ScriptInfo[] = []; @@ -672,18 +769,42 @@ namespace ts.server { return referencingProjects; } + reloadProjects() { + // First check if there is new tsconfig file added for inferred project roots + for (let info of this.openFileRoots) { + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + } + + /** + * This function is to update the project structure for every projects. + * It is called on the premise that all the configured projects are + * up to date. + */ updateProjectStructure() { this.log("updating project structure from ...", "Info"); this.printProjects(); + let unattachedOpenFiles: ScriptInfo[] = []; + let openFileRootsConfigured: ScriptInfo[] = []; + for (let info of this.openFileRootsConfigured) { + let project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + // First loop through all open files that are referenced by projects but are not // project roots. For each referenced file, see if the default project still // references that file. If so, then just keep the file in the referenced list. // If not, add the file to an unattached list, to be rechecked later. - var openFilesReferenced: ScriptInfo[] = []; - var unattachedOpenFiles: ScriptInfo[] = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -793,35 +914,40 @@ namespace ts.server { * Open file whose contents is managed by the client * @param filename is absolute pathname */ - openClientFile(fileName: string) { - var searchPath = ts.normalizePath(getDirectoryPath(fileName)); - this.log("Search path: " + searchPath,"Info"); - var configFileName = this.findConfigFile(searchPath); - if (configFileName) { - this.log("Config file name: " + configFileName, "Info"); - } else { - this.log("no config file"); - } - if (configFileName) { - configFileName = getAbsolutePath(configFileName, searchPath); - } - if (configFileName && (!this.configProjectIsActive(configFileName))) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); - } - else { - this.log("Opened configuration file " + configFileName,"Info"); - this.configuredProjects.push(configResult.project); - } - } + this.openOrUpdateConfiguredProjectForFile(fileName); var info = this.openFile(fileName, true); this.addOpenFile(info); this.printProjects(); return info; } + openOrUpdateConfiguredProjectForFile(fileName: string) { + let searchPath = ts.normalizePath(getDirectoryPath(fileName)); + this.log("Search path: " + searchPath, "Info"); + let configFileName = this.findConfigFile(searchPath); + if (configFileName) { + this.log("Config file name: " + configFileName, "Info"); + let project = this.findConfiguredProjectByConfigFile(configFileName); + if (!project) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } + } + else { + this.updateConfiguredProject(project); + } + } + else { + this.log("No config files found."); + } + } + /** * Close file whose contents is managed by the client * @param filename is absolute pathname @@ -874,7 +1000,7 @@ namespace ts.server { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var project = this.configuredProjects[i]; project.updateGraph(); - this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString()); + this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); this.psLogger.info(project.filesToString()); this.psLogger.info("-----------------------------------------------"); } @@ -898,48 +1024,113 @@ namespace ts.server { } configProjectIsActive(fileName: string) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; - } - } - return false; + return this.findConfiguredProjectByConfigFile(fileName) === undefined; } - openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + findConfiguredProjectByConfigFile(configFileName: string) { + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; + } + } + return undefined; + } + + configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) var dirPath = ts.getDirectoryPath(configFilename); - var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.readConfigFile(configFilename); + var contents = this.host.readFile(configFilename) + var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents); if (rawConfig.error) { - return rawConfig.error; + return { succeeded: false, error: rawConfig.error }; } else { var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { errorMsg: "tsconfig option errors" }; + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames) { + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } } + } + else { var projectOptions: ProjectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; - var proj = this.createProject(configFilename, projectOptions); - for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { - var rootFilename = parsedCommandLine.fileNames[i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } + return { succeeded: true, projectOptions }; + } + } + + } + + openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename); + if (!succeeded) { + return error; + } + else { + let proj = this.createProject(configFilename, projectOptions); + for (let i = 0, len = projectOptions.files.length; i < len; i++) { + let rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + let info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); + proj.addRoot(info); } - proj.finishGraph(); - return { success: true, project: proj }; + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + proj.finishGraph(); + proj.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(proj)); + return { success: true, project: proj }; + } + } + + updateConfiguredProject(project: Project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename); + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + let oldFileNames = project.compilerService.host.roots.map(info => info.fileName); + let newFileNames = projectOptions.files; + let fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0); + let fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0); + + for (let fileName of fileNamesToRemove) { + let info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + + for (let fileName of fileNamesToAdd) { + let info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + // if the root file was opened by client, it would belong to either + // openFileRoots or openFileReferenced. + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + } + } + project.addRoot(info); + } + + project.setProjectOptions(projectOptions); + project.finishGraph(); } } } @@ -992,6 +1183,7 @@ namespace ts.server { InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, } diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 8f7237382e5..438b152a1f4 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -123,9 +123,14 @@ declare module NodeJS { export interface ReadWriteStream extends ReadableStream, WritableStream { } + interface WindowSize { + columns: number; + rows: number; + } + export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; + stdout: WritableStream & WindowSize; + stderr: WritableStream & WindowSize; stdin: ReadableStream; argv: string[]; execPath: string; diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 017a8c1d81a..ce918abda3c 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -31,6 +31,12 @@ declare namespace ts.server.protocol { */ arguments?: any; } + + /** + * Request to reload the project structure for all the opened files + */ + export interface ReloadProjectsRequest extends Message { + } /** * Server-initiated event message @@ -116,7 +122,7 @@ declare namespace ts.server.protocol { /** * The list of normalized file name in the project, including 'lib.d.ts' */ - fileNameList?: string[]; + fileNames?: string[]; } /** @@ -156,6 +162,17 @@ declare namespace ts.server.protocol { arguments: FileLocationRequestArgs; } + /** + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ + export interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + /** + * List of files to search for document highlights. + */ + filesToSearch: string[]; + } + /** * Go to definition request; value of command field is * "definition". Return response giving the file locations that @@ -238,6 +255,35 @@ declare namespace ts.server.protocol { body?: OccurrencesResponseItem[]; } + /** + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ + export interface DocumentHighlightsRequest extends FileLocationRequest { + arguments: DocumentHighlightsRequestArgs + } + + export interface HighlightSpan extends TextSpan { + kind: string + } + + export interface DocumentHighlightsItem { + /** + * File containing highlight spans. + */ + file: string, + + /** + * Spans to highlight in file. + */ + highlightSpans: HighlightSpan[]; + } + + export interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + /** * Find references request; value of command field is * "references". Return response giving the file locations that @@ -412,6 +458,9 @@ declare namespace ts.server.protocol { /** Defines space handling after opening and before closing non empty parenthesis. Default value is false. */ insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + + /** Defines space handling after opening and before closing non empty brackets. Default value is false. */ + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; /** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */ placeOpenBraceOnNewLineForFunctions?: boolean; @@ -854,6 +903,31 @@ declare namespace ts.server.protocol { export interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } + + /** + * Arguments for GeterrForProject request. + */ + export interface GeterrForProjectRequestArgs { + /** + * the file requesting project error list + */ + file: string; + + /** + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ + delay: number; + } + + /** + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ + export interface GeterrForProjectRequest extends Request { + arguments: GeterrForProjectRequestArgs + } /** * Arguments for geterr messages. diff --git a/src/server/session.ts b/src/server/session.ts index 9a5cee32264..da044e7b4c6 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -86,9 +86,11 @@ namespace ts.server { export const Format = "format"; export const Formatonkey = "formatonkey"; export const Geterr = "geterr"; + export const GeterrForProject = "geterrForProject"; export const NavBar = "navbar"; export const Navto = "navto"; export const Occurrences = "occurrences"; + export const DocumentHighlights = "documentHighlights"; export const Open = "open"; export const Quickinfo = "quickinfo"; export const References = "references"; @@ -98,6 +100,7 @@ namespace ts.server { export const SignatureHelp = "signatureHelp"; export const TypeDefinition = "typeDefinition"; export const ProjectInfo = "projectInfo"; + export const ReloadProjects = "reloadProjects"; export const Unknown = "unknown"; } @@ -224,6 +227,10 @@ namespace ts.server { this.syntacticCheck(file, project); this.semanticCheck(file, project); } + + private reloadProjects() { + this.projectService.reloadProjects(); + } private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { setTimeout(() => { @@ -234,7 +241,7 @@ namespace ts.server { } private updateErrorCheck(checkList: PendingErrorCheck[], seq: number, - matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200) { + matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200, requireOpen = true) { if (followMs > ms) { followMs = ms; } @@ -249,7 +256,7 @@ namespace ts.server { var checkOne = () => { if (matchSeq(seq)) { var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { this.syntacticCheck(checkSpec.fileName, checkSpec.project); this.immediateId = setImmediate(() => { this.semanticCheck(checkSpec.fileName, checkSpec.project); @@ -313,7 +320,7 @@ namespace ts.server { })); } - private getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[]{ + private getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[] { fileName = ts.normalizePath(fileName); let project = this.projectService.getProjectForFile(fileName); @@ -343,6 +350,42 @@ namespace ts.server { }); } + private getDocumentHighlights(line: number, offset: number, fileName: string, filesToSearch: string[]): protocol.DocumentHighlightsItem[] { + fileName = ts.normalizePath(fileName); + let project = this.projectService.getProjectForFile(fileName); + + if (!project) { + throw Errors.NoProject; + } + + let { compilerService } = project; + let position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + + let documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + + if (!documentHighlights) { + return undefined; + } + + return documentHighlights.map(convertToDocumentHighlightsItem); + + function convertToDocumentHighlightsItem(documentHighlights: ts.DocumentHighlights): ts.server.protocol.DocumentHighlightsItem { + let { fileName, highlightSpans } = documentHighlights; + + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + + function convertHighlightSpan(highlightSpan: ts.HighlightSpan): ts.server.protocol.HighlightSpan { + let { textSpan, kind } = highlightSpan; + let start = compilerService.host.positionToLineOffset(fileName, textSpan.start); + let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + return { start, end, kind }; + } + } + } + private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo { fileName = ts.normalizePath(fileName) let project = this.projectService.getProjectForFile(fileName) @@ -352,7 +395,7 @@ namespace ts.server { } if (needFileNameList) { - projectInfo.fileNameList = project.getFileNameList(); + projectInfo.fileNames = project.getFileNames(); } return projectInfo; @@ -836,7 +879,53 @@ namespace ts.server { })); } - public exit() { + getDiagnosticsForProject(delay: number, fileName: string) { + let { configFileName, fileNames: fileNamesInProject } = this.getProjectInfo(fileName, true); + // No need to analyze lib.d.ts + fileNamesInProject = fileNamesInProject.filter((value, index, array) => value.indexOf("lib.d.ts") < 0); + + // Sort the file name list to make the recently touched files come first + let highPriorityFiles: string[] = []; + let mediumPriorityFiles: string[] = []; + let lowPriorityFiles: string[] = []; + let veryLowPriorityFiles: string[] = []; + let normalizedFileName = ts.normalizePath(fileName); + let project = this.projectService.getProjectForFile(normalizedFileName); + for (let fileNameInProject of fileNamesInProject) { + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + let info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + + if (fileNamesInProject.length > 0) { + let checkList = fileNamesInProject.map((fileName: string) => { + let normalizedFileName = ts.normalizePath(fileName); + return { fileName: normalizedFileName, project }; + }); + // Project level error analysis runs on background files too, therefore + // doesn't require the file to be opened + this.updateErrorCheck(checkList, this.changeSeq, (n) => n == this.changeSeq, delay, 200, /*requireOpen*/ false); + } + } + + getCanonicalFileName(fileName: string) { + let name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + } + + exit() { } private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { @@ -894,6 +983,10 @@ namespace ts.server { var geterrArgs = request.arguments; return {response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false}; }, + [CommandNames.GeterrForProject]: (request: protocol.Request) => { + let { file, delay } = request.arguments; + return {response: this.getDiagnosticsForProject(delay, file), responseRequired: false}; + }, [CommandNames.Change]: (request: protocol.Request) => { var changeArgs = request.arguments; this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, @@ -937,10 +1030,18 @@ namespace ts.server { var { line, offset, file: fileName } = request.arguments; return {response: this.getOccurrences(line, offset, fileName), responseRequired: true}; }, + [CommandNames.DocumentHighlights]: (request: protocol.Request) => { + var { line, offset, file: fileName, filesToSearch } = request.arguments; + return {response: this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true}; + }, [CommandNames.ProjectInfo]: (request: protocol.Request) => { var { file, needFileNameList } = request.arguments; return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, + [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { + this.reloadProjects(); + return {responseRequired: false}; + } }; public addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { if (this.handlers[command]) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 19ce73288bc..44b9797938f 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -39,12 +39,12 @@ namespace ts.formatting { public SpaceBetweenCloseBraceAndWhile: Rule; public NoSpaceAfterCloseBrace: Rule; - // No space for indexer and dot + // No space for dot public NoSpaceBeforeDot: Rule; public NoSpaceAfterDot: Rule; + + // No space before and after indexer public NoSpaceBeforeOpenBracket: Rule; - public NoSpaceAfterOpenBracket: Rule; - public NoSpaceBeforeCloseBracket: Rule; public NoSpaceAfterCloseBracket: Rule; // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. @@ -135,6 +135,7 @@ namespace ts.formatting { public NoSpaceAfterOpenAngularBracket: Rule; public NoSpaceBeforeCloseAngularBracket: Rule; public NoSpaceAfterCloseAngularBracket: Rule; + public NoSpaceAfterTypeAssertion: Rule; // Remove spaces in empty interface literals. e.g.: x: {} public NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; @@ -190,6 +191,13 @@ namespace ts.formatting { public NoSpaceAfterOpenParen: Rule; public NoSpaceBeforeCloseParen: Rule; + // Insert space after opening and before closing nonempty brackets + public SpaceAfterOpenBracket: Rule; + public SpaceBeforeCloseBracket: Rule; + public NoSpaceBetweenBrackets: Rule; + public NoSpaceAfterOpenBracket: Rule; + public NoSpaceBeforeCloseBracket: Rule; + // Insert space after function keyword for anonymous functions public SpaceAfterAnonymousFunctionKeyword: Rule; public NoSpaceAfterAnonymousFunctionKeyword: Rule; @@ -205,6 +213,26 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; + // Async-await + public SpaceBetweenAsyncAndFunctionKeyword: Rule; + public NoSpaceBetweenAsyncAndFunctionKeyword: Rule; + public SpaceAfterAwaitKeyword: Rule; + public NoSpaceAfterAwaitKeyword: Rule; + + // Type alias declaration + public SpaceAfterTypeKeyword: Rule; + public NoSpaceAfterTypeKeyword: Rule; + + // Tagged template string + public SpaceBetweenTagAndTemplateString: Rule; + public NoSpaceBetweenTagAndTemplateString: Rule; + + // Union type + public SpaceBeforeBar: Rule; + public NoSpaceBeforeBar: Rule; + public SpaceAfterBar: Rule; + public NoSpaceAfterBar: Rule; + constructor() { /// /// Common Rules @@ -231,13 +259,13 @@ namespace ts.formatting { this.SpaceBetweenCloseBraceAndWhile = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken, SyntaxKind.SemicolonToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - // No space for indexer and dot + // No space for dot this.NoSpaceBeforeDot = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.DotToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.NoSpaceAfterDot = new Rule(RuleDescriptor.create3(SyntaxKind.DotToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // No space before and after indexer this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete)); + this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext ), RuleAction.Delete)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments; @@ -331,12 +359,13 @@ namespace ts.formatting { this.NoSpaceAfterEllipsis = new Rule(RuleDescriptor.create1(SyntaxKind.DotDotDotToken, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.NoSpaceAfterOptionalParameters = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.TypeNames, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), RuleAction.Delete)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new Rule(RuleDescriptor.create1(SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), RuleAction.Delete)); - this.NoSpaceAfterOpenAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.LessThanToken, Shared.TokenRange.TypeNames), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), RuleAction.Delete)); - this.NoSpaceAfterCloseAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.FromTokens([SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), RuleAction.Delete)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.TypeNames, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new Rule(RuleDescriptor.create1(SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); + this.NoSpaceAfterOpenAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.LessThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); + this.NoSpaceAfterCloseAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.FromTokens([SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); + this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete)); // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete)); @@ -351,6 +380,27 @@ namespace ts.formatting { this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete)); this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // Type alias declaration + this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // template string + this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // union type + this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -377,6 +427,11 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, @@ -391,6 +446,7 @@ namespace ts.formatting { this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -402,8 +458,8 @@ namespace ts.formatting { this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -448,6 +504,13 @@ namespace ts.formatting { this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete)); @@ -704,13 +767,15 @@ namespace ts.formatting { return context.contextNode.kind === SyntaxKind.TypeLiteral;// && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } - static IsTypeArgumentOrParameter(token: TextRangeWithKind, parent: Node): boolean { + static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean { if (token.kind !== SyntaxKind.LessThanToken && token.kind !== SyntaxKind.GreaterThanToken) { return false; } switch (parent.kind) { case SyntaxKind.TypeReference: + case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: @@ -721,6 +786,7 @@ namespace ts.formatting { case SyntaxKind.ConstructSignature: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: + case SyntaxKind.ExpressionWithTypeArguments: return true; default: return false; @@ -728,9 +794,13 @@ namespace ts.formatting { } } - static IsTypeArgumentOrParameterContext(context: FormattingContext): boolean { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + } + + static IsTypeAssertionContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.TypeAssertionExpression; } static IsVoidOpContext(context: FormattingContext): boolean { diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index ac1494571d1..f6cf1de474b 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -71,6 +71,17 @@ namespace ts.formatting { rules.push(this.globalRules.NoSpaceBetweenParens); } + if ( options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets ) { + rules.push( this.globalRules.SpaceAfterOpenBracket ); + rules.push( this.globalRules.SpaceBeforeCloseBracket ); + rules.push( this.globalRules.NoSpaceBetweenBrackets ); + } + else { + rules.push( this.globalRules.NoSpaceAfterOpenBracket ); + rules.push( this.globalRules.NoSpaceBeforeCloseBracket ); + rules.push( this.globalRules.NoSpaceBetweenBrackets ); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index db748f7f494..ebbf09e9feb 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -408,6 +408,7 @@ namespace ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: @@ -418,6 +419,7 @@ namespace ts.formatting { case SyntaxKind.DefaultClause: case SyntaxKind.CaseClause: case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.VariableStatement: @@ -427,6 +429,17 @@ namespace ts.formatting { case SyntaxKind.ConditionalExpression: case SyntaxKind.ArrayBindingPattern: case SyntaxKind.ObjectBindingPattern: + case SyntaxKind.JsxElement: + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.Parameter: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.UnionType: + case SyntaxKind.ParenthesizedType: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AwaitExpression: return true; } return false; @@ -446,8 +459,6 @@ namespace ts.formatting { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: case SyntaxKind.ArrowFunction: case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: diff --git a/src/services/services.ts b/src/services/services.ts index 31ef199015e..27bc4ae36cb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -73,7 +73,7 @@ namespace ts { } /** - * Represents an immutable snapshot of a script at a specified time.Once acquired, the + * 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. */ @@ -85,9 +85,9 @@ namespace ts { getLength(): number; /** - * Gets the TextChangeRange that describe how the text changed between this text and + * 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 + * 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. */ @@ -125,12 +125,53 @@ namespace ts { export interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean } let scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); let emptyArray: any[] = []; + + const jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + let jsDocCompletionEntries: CompletionEntry[]; function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject { let node = new (getNodeConstructor(kind))(); @@ -261,26 +302,29 @@ namespace ts { } public getFirstToken(sourceFile?: SourceFile): Node { - let children = this.getChildren(); - for (let child of children) { - if (child.kind < SyntaxKind.FirstNode) { - return child; - } - - return child.getFirstToken(sourceFile); + let children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + + let child = children[0]; + + return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile); } public getLastToken(sourceFile?: SourceFile): Node { let children = this.getChildren(sourceFile); - for (let i = children.length - 1; i >= 0; i--) { - let child = children[i]; - if (child.kind < SyntaxKind.FirstNode) { - return child; - } - return child.getLastToken(sourceFile); + let child = lastOrUndefined(children); + if (!child) { + return undefined; } + + return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); + } + + public createParentNavigator(): ParentNavigator { + return createParentNavigator(this); } } @@ -337,10 +381,10 @@ namespace ts { ts.forEach(declarations, (declaration, indexOfDeclaration) => { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array if (indexOf(declarations, declaration) === indexOfDeclaration) { let sourceFileOfDeclaration = getSourceFileOfNode(declaration); @@ -362,7 +406,7 @@ namespace ts { // If this is dotted module name, get the doc comments from the parent while (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.parent.kind === SyntaxKind.ModuleDeclaration) { declaration = declaration.parent; - } + } // Get the cleaned js doc comment text from the declaration ts.forEach(getJsDocCommentTextRange( @@ -382,7 +426,7 @@ namespace ts { jsDocComment => { return { pos: jsDocComment.pos + "/*".length, // Consume /* from the comment - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -487,7 +531,7 @@ namespace ts { pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); blankLineCount = 0; } - else if (!isInParamTag && docComments.length) { + else if (!isInParamTag && docComments.length) { // This is blank line when there is text already parsed blankLineCount++; } @@ -503,7 +547,7 @@ namespace ts { if (isParamTag(pos, end, sourceFile)) { let blankLineCount = 0; let recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -561,7 +605,7 @@ namespace ts { while (pos < end) { let ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -627,7 +671,7 @@ namespace ts { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max let startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -762,7 +806,8 @@ namespace ts { public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; - + public resolvedModules: Map; + public imports: LiteralExpression[]; private namedDeclarations: Map; public update(newText: string, textChangeRange: TextChangeRange): SourceFile { @@ -975,6 +1020,13 @@ namespace ts { trace? (s: string): void; error? (s: string): void; useCaseSensitiveFileNames? (): boolean; + + /* + * LS host can optionally implement this method if it wants to be completely in charge of module name resolution. + * if implementation is omitted then language service will use built-in module resolution logic and get answers to + * host specific questions using 'getScriptSnapshot'. + */ + resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; } // @@ -991,17 +1043,17 @@ namespace ts { // diagnostics present for the program level, and not just 'options' diagnostics. getCompilerOptionsDiagnostics(): Diagnostic[]; - /** + /** * @deprecated Use getEncodedSyntacticClassifications instead. */ getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - /** + /** * @deprecated Use getEncodedSemanticClassifications instead. */ getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - // Encoded as triples of [start, length, ClassificationType]. + // Encoded as triples of [start, length, ClassificationType]. getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; @@ -1041,6 +1093,8 @@ namespace ts { getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; + getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; @@ -1087,6 +1141,12 @@ namespace ts { newText: string; } + export interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + export interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1142,6 +1202,7 @@ namespace ts { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number| string; @@ -1220,7 +1281,7 @@ namespace ts { * 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 + * 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?'. */ export interface SignatureHelpItem { @@ -1274,8 +1335,8 @@ namespace ts { /** The text to display in the editor for the collapsed region. */ bannerText: string; - /** - * Whether or not this region should be automatically collapsed when + /** + * Whether or not this region should be automatically collapsed when * the 'Collapse to Definitions' command is invoked. */ autoCollapse: boolean; @@ -1356,18 +1417,18 @@ namespace ts { } /** - * The document registry represents a store of SourceFile objects that can be shared between + * The document registry represents a store of SourceFile objects that can be shared between * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library * file (lib.d.ts). * - * A more advanced use of the document registry is to serialize sourceFile objects to disk + * A more advanced use of the document registry is to serialize sourceFile objects to disk * and re-hydrate them when needed. * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it * to all subsequent createLanguageService calls. */ export interface DocumentRegistry { @@ -1377,7 +1438,7 @@ namespace ts { * the SourceFile if was not found in the registry. * * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the + * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. * @parm scriptSnapshot Text of the file. Only used if the file was not found @@ -1397,10 +1458,10 @@ namespace ts { * to get an updated SourceFile. * * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the + * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. + * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ updateDocument( @@ -1561,13 +1622,6 @@ namespace ts { /// Language Service - interface FormattingOptions { - useTabs: boolean; - spacesPerTab: number; - indentSpaces: number; - newLineCharacter: string; - } - // Information about a specific host file. interface HostFileInformation { hostFileName: string; @@ -1579,7 +1633,7 @@ namespace ts { sourceFile: SourceFile; // The number of language services that this source file is referenced in. When no more - // language services are referencing the file, then the file can be removed from the + // language services are referencing the file, then the file can be removed from the // registry. languageServiceRefCount: number; owners: string[]; @@ -1634,8 +1688,8 @@ namespace ts { }; } - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. class HostCache { private fileNameToEntry: FileMap; @@ -1714,8 +1768,8 @@ namespace ts { } class SyntaxTreeCache { - // For our syntactic only features, we also keep a cache of the syntax tree for the - // currently edited file. + // For our syntactic only features, we also keep a cache of the syntax tree for the + // currently edited file. private currentFileName: string; private currentFileVersion: string; private currentFileScriptSnapshot: IScriptSnapshot; @@ -1760,20 +1814,21 @@ namespace ts { sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - + export interface TranspileOptions { compilerOptions?: CompilerOptions; fileName?: string; reportDiagnostics?: boolean; moduleName?: string; + renamedDependencies?: Map; } - + export interface TranspileOutput { outputText: string; diagnostics?: Diagnostic[]; sourceMapText?: string; } - + /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. @@ -1783,7 +1838,7 @@ namespace ts { * - noLib = true * - noResolve = true */ - export function transpileModule(input: string, transpileOptions?: TranspileOptions): TranspileOutput { + export function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput { let options = transpileOptions.compilerOptions ? clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; @@ -1791,7 +1846,7 @@ namespace ts { // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; @@ -1806,12 +1861,13 @@ namespace ts { sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + let newLine = getNewLineCharacter(options); // Output let outputText: string; let sourceMapText: string; - // Create a compilerHost object to allow the compiler to read and write files let compilerHost: CompilerHost = { getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, @@ -1829,11 +1885,13 @@ namespace ts { useCaseSensitiveFileNames: () => false, getCanonicalFileName: fileName => fileName, getCurrentDirectory: () => "", - getNewLine: () => newLine + getNewLine: () => newLine, + fileExists: (fileName): boolean => fileName === inputFileName, + readFile: (fileName): string => "" }; let program = createProgram([inputFileName], options, compilerHost); - + let diagnostics: Diagnostic[]; if (transpileOptions.reportDiagnostics) { diagnostics = []; @@ -1845,11 +1903,11 @@ namespace ts { Debug.assert(outputText !== undefined, "Output generation failed"); - return { outputText, diagnostics, sourceMapText }; + return { outputText, diagnostics, sourceMapText }; } /* - * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. */ export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string { let output = transpileModule(input, { compilerOptions, fileName, reportDiagnostics: !!diagnostics, moduleName }); @@ -1870,19 +1928,19 @@ namespace ts { export let disableIncrementalParsing = false; export function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!disableIncrementalParsing) { let newText: string; - + // grab the fragment from the beginning of the original text to the beginning of the span let prefix = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) : ""; - + // grab the fragment from the end of the span till the end of the original text let suffix = textSpanEnd(textChangeRange.span) !== sourceFile.text.length ? sourceFile.text.substr(textSpanEnd(textChangeRange.span)) @@ -1896,10 +1954,10 @@ namespace ts { // it was actual edit, fetch the fragment of new text that correspond to new span let changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); // combine prefix, changed text and suffix - newText = prefix && suffix + newText = prefix && suffix ? prefix + changedText + suffix : prefix - ? (prefix + changedText) + ? (prefix + changedText) : (changedText + suffix); } @@ -1927,7 +1985,7 @@ namespace ts { return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } - function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string { + export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string { return useCaseSensitivefileNames ? ((fileName) => fileName) : ((fileName) => fileName.toLowerCase()); @@ -1941,7 +1999,7 @@ namespace ts { let getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings: CompilerOptions): string { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): FileMap { @@ -2005,7 +2063,7 @@ namespace ts { bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -2050,6 +2108,7 @@ namespace ts { export function preProcessFile(sourceText: string, readImportFiles = true): PreProcessedFileInfo { let referencedFiles: FileReference[] = []; let importedFiles: FileReference[] = []; + let ambientExternalModules: string[]; let isNoDefaultLib = false; function processTripleSlashDirectives(): void { @@ -2067,6 +2126,13 @@ namespace ts { }); } + function recordAmbientExternalModule(): void { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } + function recordModuleName() { let importPath = scanner.getTokenValue(); let pos = scanner.getTokenPos(); @@ -2092,7 +2158,18 @@ namespace ts { // export {a as b} from "mod" while (token !== SyntaxKind.EndOfFileToken) { - if (token === SyntaxKind.ImportKeyword) { + if (token === SyntaxKind.DeclareKeyword) { + // declare module "mod" + token = scanner.scan(); + if (token === SyntaxKind.ModuleKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === SyntaxKind.ImportKeyword) { token = scanner.scan(); if (token === SyntaxKind.StringLiteral) { // import "mod"; @@ -2100,7 +2177,7 @@ namespace ts { continue; } else { - if (token === SyntaxKind.Identifier) { + if (token === SyntaxKind.Identifier || isKeyword(token)) { token = scanner.scan(); if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); @@ -2157,7 +2234,7 @@ namespace ts { token = scanner.scan(); if (token === SyntaxKind.AsKeyword) { token = scanner.scan(); - if (token === SyntaxKind.Identifier) { + if (token === SyntaxKind.Identifier || isKeyword(token)) { token = scanner.scan(); if (token === SyntaxKind.FromKeyword) { token = scanner.scan(); @@ -2213,7 +2290,7 @@ namespace ts { processImport(); } processTripleSlashDirectives(); - return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules }; } /// Helpers @@ -2520,29 +2597,49 @@ namespace ts { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. let oldSettings = program && program.getCompilerOptions(); let newSettings = hostCache.compilationSettings(); - let changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + let changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - let newProgram = createProgram(hostCache.getRootFileNames(), newSettings, { + let compilerHost: CompilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: () => cancellationToken, getCanonicalFileName, useCaseSensitiveFileNames: () => useCaseSensitivefileNames, - getNewLine: () => host.getNewLine ? host.getNewLine() : "\r\n", + getNewLine: () => getNewLineOrDefaultFromHost(host), getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), writeFile: (fileName, data, writeByteOrderMark) => { }, - getCurrentDirectory: () => host.getCurrentDirectory() - }); + getCurrentDirectory: () => host.getCurrentDirectory(), + fileExists: (fileName): boolean => { + // stub missing host functionality + Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: (fileName): string => { + // stub missing host functionality + let entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; - // Release any files we have acquired in the old program but are + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile) + } + + let newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + + // Release any files we have acquired in the old program but are // not part of the new program. if (program) { let oldSourceFiles = program.getSourceFiles(); @@ -2560,7 +2657,7 @@ namespace ts { program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -2582,7 +2679,7 @@ namespace ts { // Check if the old program had this file already let oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // We already had a source file for this file name. Go to the registry to // ensure that we get the right up to date version of it. We need this to // address the following 'race'. Specifically, say we have the following: // @@ -2593,15 +2690,15 @@ namespace ts { // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -2667,7 +2764,7 @@ namespace ts { /** * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors - * If '-d' enabled, report both semantic and emitter errors + * If '-d' enabled, report both semantic and emitter errors */ function getSemanticDiagnostics(fileName: string): Diagnostic[] { synchronizeHostData(); @@ -2675,7 +2772,7 @@ namespace ts { let targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -2918,6 +3015,8 @@ namespace ts { let sourceFile = getValidSourceFile(fileName); let isJavaScriptFile = isJavaScript(fileName); + let isJsDocTagName = false; + let start = new Date().getTime(); let currentToken = getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -2928,8 +3027,44 @@ namespace ts { log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { + isJsDocTagName = true; + } + + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + let insideJsDocTagExpression = false; + let tag = getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + + switch (tag.kind) { + case SyntaxKind.JSDocTypeTag: + case SyntaxKind.JSDocParameterTag: + case SyntaxKind.JSDocReturnTag: + let tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName }; + } + + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); @@ -3015,7 +3150,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -3055,7 +3190,7 @@ namespace ts { } if (isJavaScriptFile && type.flags & TypeFlags.Union) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -3110,10 +3245,10 @@ namespace ts { // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -3140,7 +3275,7 @@ namespace ts { /// TODO filter meaning based on the current context let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); - + return true; } @@ -3278,7 +3413,7 @@ namespace ts { let rootDeclaration = getRootDeclaration(objectLikeContainer.parent); if (isVariableLike(rootDeclaration)) { - // We don't want to complete using the type acquired by the shape + // We don't want to complete using the type acquired by the shape // of the binding pattern; we are only interested in types acquired // through type declaration or inference. if (rootDeclaration.initializer || rootDeclaration.type) { @@ -3393,23 +3528,35 @@ namespace ts { case SyntaxKind.LessThanSlashToken: case SyntaxKind.SlashToken: case SyntaxKind.Identifier: - if(parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { return parent; } break; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case SyntaxKind.StringLiteral: + if (parent && ((parent.kind === SyntaxKind.JsxAttribute) || (parent.kind === SyntaxKind.JsxSpreadAttribute))) { + return parent.parent; + } + + break; + case SyntaxKind.CloseBraceToken: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if(parent && + if (parent && parent.kind === SyntaxKind.JsxExpression && parent.parent && - parent.parent.kind === SyntaxKind.JsxAttribute) { - + (parent.parent.kind === SyntaxKind.JsxAttribute)) { return parent.parent.parent; } + if (parent && parent.kind === SyntaxKind.JsxSpreadAttribute) { + return parent.parent; + } + break; } } @@ -3446,19 +3593,20 @@ namespace ts { containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | isFunction(containingNodeKind) || containingNodeKind === SyntaxKind.ClassDeclaration || // class A !lookUp(existingMemberNames, m.name)); } - + /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. * @@ -3643,9 +3792,14 @@ namespace ts { return undefined; } - let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot } = completionData; + let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; let entries: CompletionEntry[]; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } + if (isRightOfDot && isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); addRange(entries, getJavaScriptCompletionEntries()); @@ -3659,7 +3813,7 @@ namespace ts { } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { addRange(entries, keywordCompletions); } @@ -3692,8 +3846,19 @@ namespace ts { return entries; } + function getAllJsDocCompletionEntries(): CompletionEntry[] { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", + } + })); + } + function createCompletionEntry(symbol: Symbol, location: Node): CompletionEntry { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); @@ -3701,10 +3866,10 @@ namespace ts { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other @@ -3750,8 +3915,8 @@ namespace ts { // Find the symbol with the matching entry name. let target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location) === entryName ? s : undefined); @@ -3766,7 +3931,7 @@ namespace ts { }; } } - + // Didn't find a symbol with this name. See if we can find a keyword instead. let keywordCompletion = forEach(keywordCompletions, c => c.name === entryName); if (keywordCompletion) { @@ -3842,7 +4007,7 @@ namespace ts { Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method let typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -3916,7 +4081,7 @@ namespace ts { let allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } @@ -4022,6 +4187,7 @@ namespace ts { displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); @@ -4062,16 +4228,29 @@ namespace ts { } else { // Method/function type parameter - let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; - let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { - displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + let container = getContainingFunction(location); + if (container) { + let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); + } + else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); } } if (symbolFlags & SymbolFlags.EnumMember) { @@ -4292,7 +4471,7 @@ namespace ts { if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. + // Just add all the declarations. forEach(declarations, declaration => { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -4305,10 +4484,19 @@ namespace ts { // and in either case the symbol has a construct signature definition, i.e. class if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { if (symbol.flags & SymbolFlags.Class) { - let classDeclaration = symbol.getDeclarations()[0]; - Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration); + // Find the first class-like declaration and try to get the construct signature. + for (let declaration of symbol.getDeclarations()) { + if (isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, + symbolKind, + symbolName, + containerName, + result); + } + } - return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -4403,7 +4591,7 @@ namespace ts { // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { @@ -4469,7 +4657,7 @@ namespace ts { if (results) { let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = filter(results, r => getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile); } @@ -4608,7 +4796,7 @@ namespace ts { case SyntaxKind.BreakKeyword: case SyntaxKind.ContinueKeyword: if (hasKind(node.parent, SyntaxKind.BreakStatement) || hasKind(node.parent, SyntaxKind.ContinueStatement)) { - return getBreakOrContinueStatementOccurences(node.parent); + return getBreakOrContinueStatementOccurrences(node.parent); } break; case SyntaxKind.ForKeyword: @@ -4696,7 +4884,7 @@ namespace ts { if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) { return parent; } - + // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. if (parent.kind === SyntaxKind.TryStatement) { @@ -4790,7 +4978,7 @@ namespace ts { return undefined; } } - else { + else { // unsupported modifier return undefined; } @@ -4934,7 +5122,7 @@ namespace ts { return map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement: BreakOrContinueStatement): HighlightSpan[] { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement: BreakOrContinueStatement): HighlightSpan[] { let owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { @@ -5386,13 +5574,13 @@ namespace ts { // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). let endPosition = position + symbolNameLength; if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -5459,9 +5647,9 @@ namespace ts { return false; } - /** Search within node "container" for references for a search value, where the search value is defined as a + /** Search within node "container" for references for a search value, where the search value is defined as a * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value + * searchLocation: a node where the search value */ function getReferencesInNode(container: Node, searchSymbol: Symbol, @@ -5474,7 +5662,7 @@ namespace ts { symbolToIndex: number[]): void { let sourceFile = container.getSourceFile(); - let tripleSlashDirectivePrefixRegex = /^\/\/\/\s* token.getStart(); - } + function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean { + return isInCommentHelper(sourceFile, position, isNonReferenceComment); - function isInComment(position: number) { - let token = getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos); - - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return forEach(commentRanges, c => { - if (c.pos < position && position < c.end) { - let commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isNonReferenceComment(c: CommentRange): boolean { + let commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - - return false; } } @@ -5718,6 +5889,7 @@ namespace ts { result.push(getReferenceEntryFromNode(node)); } break; + case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. @@ -5829,7 +6001,7 @@ namespace ts { } } - // If the reference location is in an object literal, try to get the contextual type for the + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol if (isNameOfPropertyAssignment(referenceLocation)) { @@ -5846,7 +6018,7 @@ namespace ts { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { let result: Symbol[] = []; @@ -6197,7 +6369,7 @@ namespace ts { } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // If this is name of a module declarations, check if this is right side of dotted module name - // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of + // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module if (nodeForStartPos.parent.parent.kind === SyntaxKind.ModuleDeclaration && (nodeForStartPos.parent.parent).body === nodeForStartPos.parent) { @@ -6240,7 +6412,7 @@ namespace ts { // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. @@ -6313,7 +6485,7 @@ namespace ts { */ function hasValueSideModule(symbol: Symbol): boolean { return forEach(symbol.declarations, declaration => { - return declaration.kind === SyntaxKind.ModuleDeclaration && + return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) === ModuleInstanceState.Instantiated; }); } @@ -6434,8 +6606,8 @@ namespace ts { // Only bother with the trivia if it at least intersects the span of interest. if (isComment(kind)) { classifyComment(token, kind, start, width); - - // Classifying a comment might cause us to reuse the trivia scanner + + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); @@ -6486,7 +6658,7 @@ namespace ts { for (let tag of docComment.tags) { // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -6548,7 +6720,7 @@ namespace ts { } function classifyDisabledMergeCode(text: string, start: number, end: number) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (isLineBreak(text.charCodeAt(i))) { @@ -6591,7 +6763,7 @@ namespace ts { } } - // for accurate classification, the actual token should be passed in. however, for + // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. function classifyTokenType(tokenKind: SyntaxKind, token?: Node): ClassificationType { @@ -6805,12 +6977,84 @@ namespace ts { return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion { + let start = new Date().getTime(); + let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + + // Check if in a context where we don't want to perform any insertion + if (isInString(sourceFile, position) || isInComment(sourceFile, position) || hasDocComment(sourceFile, position)) { + return undefined; + } + + let tokenAtPos = getTokenAtPosition(sourceFile, position); + let tokenStart = tokenAtPos.getStart() + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + + // TODO: add support for: + // - methods + // - constructors + // - class decls + let containingFunction = getAncestor(tokenAtPos, SyntaxKind.FunctionDeclaration); + + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + + let parameters = containingFunction.parameters; + let posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + let lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + + let indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + + // TODO: call a helper method instead once PR #4133 gets merged in. + const newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + + let docParams = parameters.reduce((prev, cur, index) => + prev + + indentationStr + " * @param " + (cur.name.kind === SyntaxKind.Identifier ? (cur.name).text : "param" + index) + newLine, ""); + + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + const preamble = "/**" + newLine + + indentationStr + " * "; + let result = + preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + + return { newText: result, caretOffset: preamble.length }; + } + function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); @@ -6840,7 +7084,7 @@ namespace ts { // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -6866,7 +7110,7 @@ namespace ts { } Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -6918,11 +7162,11 @@ namespace ts { // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. let literals = "(?:" + map(descriptors, d => "(" + escapeRegExp(d.text) + ")").join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). let endOfLineOrEndOfComment = /(?:$|\*\/)/.source let messageRemainder = /(?:.*?)/.source @@ -7046,6 +7290,7 @@ namespace ts { getFormattingEditsForRange, getFormattingEditsForDocument, getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition, getEmitOutput, getSourceFile, getProgram @@ -7104,7 +7349,7 @@ namespace ts { /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. let noRegexTable: boolean[] = []; noRegexTable[SyntaxKind.Identifier] = true; @@ -7150,7 +7395,7 @@ namespace ts { keyword2 === SyntaxKind.ConstructorKeyword || keyword2 === SyntaxKind.StaticKeyword) { - // Allow things like "public get", "public constructor" and "public static". + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -7221,7 +7466,7 @@ namespace ts { function getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult { return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } - + // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications { @@ -7283,12 +7528,12 @@ namespace ts { // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. let angleBracketStack = 0; @@ -7306,7 +7551,7 @@ namespace ts { token = SyntaxKind.Identifier; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. @@ -7314,7 +7559,7 @@ namespace ts { } else if (lastNonTriviaToken === SyntaxKind.Identifier && token === SyntaxKind.LessThanToken) { - // Could be the start of something generic. Keep track of that by bumping + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } @@ -7329,7 +7574,7 @@ namespace ts { token === SyntaxKind.BooleanKeyword || token === SyntaxKind.SymbolKeyword) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. token = SyntaxKind.Identifier; @@ -7437,8 +7682,8 @@ namespace ts { } if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of // the original text. start += offset; } @@ -7561,11 +7806,11 @@ namespace ts { /// getDefaultLibraryFilePath declare let __dirname: string; - + /** * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. + * The functionality is not supported if the ts module is consumed outside of a node module. */ export function getDefaultLibFilePath(options: CompilerOptions): string { // Check __dirname is defined and that we are on a node.js system. diff --git a/src/services/shims.ts b/src/services/shims.ts index ae853e1c72a..307062cebd8 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -60,10 +60,12 @@ namespace ts { getNewLine?(): string; getProjectVersion?(): string; useCaseSensitiveFileNames?(): boolean; + + getModuleResolutionsForFile?(fileName: string): string; } /** Public interface of the the of a config service shim instance.*/ - export interface CoreServicesShimHost extends Logger { + export interface CoreServicesShimHost extends Logger, ModuleResolutionHost { /** * Returns a JSON-encoded value of the type: string[] * @@ -205,6 +207,11 @@ namespace ts { getFormattingEditsForDocument(fileName: string, options: string/*Services.FormatCodeOptions*/): string; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string/*Services.FormatCodeOptions*/): string; + /** + * Returns JSON-encoded value of the type TextInsertion. + */ + getDocCommentTemplateAtPosition(fileName: string, position: number): string; + getEmitOutput(fileName: string): string; } @@ -265,8 +272,18 @@ namespace ts { private files: string[]; private loggingEnabled = false; private tracingEnabled = false; - + + public resolveModuleNames: (moduleName: string[], containingFile: string) => string[]; + constructor(private shimHost: LanguageServiceShimHost) { + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { + let resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); + return map(moduleNames, name => lookUp(resolutionsInFile, name)); + }; + } } public log(s: string): void { @@ -405,6 +422,14 @@ namespace ts { } return JSON.parse(encoded); } + + public fileExists(fileName: string): boolean { + return this.shimHost.fileExists(fileName); + } + + public readFile(fileName: string): string { + return this.shimHost.readFile(fileName); + } } function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any { @@ -529,7 +554,7 @@ namespace ts { } private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[]{ - var newLine = this.getNewLine(); + var newLine = getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); } @@ -571,10 +596,6 @@ namespace ts { }); } - private getNewLine(): string { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - } - public getSyntacticDiagnostics(fileName: string): string { return this.forwardJSONCall( "getSyntacticDiagnostics('" + fileName + "')", @@ -751,7 +772,10 @@ namespace ts { return this.forwardJSONCall( "getDocumentHighlights('" + fileName + "', " + position + ")", () => { - return this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + let normalizedName = normalizeSlashes(fileName).toLowerCase(); + return filter(results, r => normalizeSlashes(r.fileName).toLowerCase() === normalizedName); }); } @@ -811,6 +835,13 @@ namespace ts { }); } + public getDocCommentTemplateAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + "getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", + () => this.languageService.getDocCommentTemplateAtPosition(fileName, position) + ); + } + /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -907,6 +938,13 @@ namespace ts { private forwardJSONCall(actionDescription: string, action: () => any): any { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); } + + public resolveModuleName(fileName: string, moduleName: string, compilerOptionsJson: string): string { + return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { + let compilerOptions = JSON.parse(compilerOptionsJson); + return resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); + }); + } public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { return this.forwardJSONCall( @@ -916,6 +954,7 @@ namespace ts { var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; @@ -1058,4 +1097,4 @@ module TypeScript.Services { } /* @internal */ -let toolsVersion = "1.5"; +const toolsVersion = "1.6"; diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index f44ebade2a7..df321647e5c 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -611,13 +611,11 @@ namespace ts.SignatureHelp { let displayParts = mapToDisplayParts(writer => typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation)); - let isOptional = hasQuestionToken(parameter.valueDeclaration); - return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts, - isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5f8859c815e..d5ad93260cd 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -414,6 +414,93 @@ namespace ts { } } } + + export function isInString(sourceFile: SourceFile, position: number) { + let token = getTokenAtPosition(sourceFile, position); + return token && token.kind === SyntaxKind.StringLiteral && position > token.getStart(); + } + + export function isInComment(sourceFile: SourceFile, position: number) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + export function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean { + let token = getTokenAtPosition(sourceFile, position); + + if (token && position <= token.getStart()) { + let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos); + + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + forEach(commentRanges, c => c.pos < position && + (c.kind == SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end) && + predicate(c)) : + forEach(commentRanges, c => c.pos < position && + (c.kind == SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end)); + } + + return false; + } + + export function hasDocComment(sourceFile: SourceFile, position: number) { + let token = getTokenAtPosition(sourceFile, position); + + // First, we have to see if this position actually landed in a comment. + let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos); + + return forEach(commentRanges, jsDocPrefix); + + function jsDocPrefix(c: CommentRange): boolean { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + export function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag { + let node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case SyntaxKind.VarKeyword: + case SyntaxKind.LetKeyword: + case SyntaxKind.ConstKeyword: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + + if (node) { + let jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (let tag of jsDocComment.tags) { + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + + return undefined; + } function nodeHasTokens(n: Node): boolean { // If we have a token or node that has a non-zero width, it must have tokens. @@ -586,7 +673,6 @@ namespace ts { else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; } else if (flags & SymbolFlags.Alias) { return SymbolDisplayPartKind.aliasName; } - return SymbolDisplayPartKind.text; } } @@ -625,6 +711,14 @@ namespace ts { return displayPart(text, SymbolDisplayPartKind.text); } + const carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + export function lineBreakPart() { return displayPart("\n", SymbolDisplayPartKind.lineBreak); } diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 30951b90fca..4a467a60a84 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - if (node.statement.kind !== 189 /* Block */) { + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + if (node.statement.kind !== 190 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 193 /* IfStatement */: + case 194 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 189 /* Block */) { + if (ifStatement.thenStatement.kind !== 190 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 189 /* Block */ && - ifStatement.elseStatement.kind !== 193 /* IfStatement */) { + ifStatement.elseStatement.kind !== 190 /* Block */ && + ifStatement.elseStatement.kind !== 194 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var op = node.operatorToken.kind; - if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { + if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); } break; @@ -112,7 +112,7 @@ exports.delint = delint; var fileNames = process.argv.slice(2); fileNames.forEach(function (fileName) { // Parse a file - var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, true); + var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, /*setParentNodes */ true); // delint it delint(sourceFile); }); diff --git a/tests/baselines/reference/aliasesInSystemModule1.js b/tests/baselines/reference/aliasesInSystemModule1.js index 28ac1e9b4ad..05f74aef852 100644 --- a/tests/baselines/reference/aliasesInSystemModule1.js +++ b/tests/baselines/reference/aliasesInSystemModule1.js @@ -22,8 +22,8 @@ System.register(['foo'], function(exports_1) { var cls, cls2, x, y, z, M; return { setters:[ - function (_alias) { - alias = _alias; + function (alias_1) { + alias = alias_1; }], execute: function() { cls = alias.Class; diff --git a/tests/baselines/reference/aliasesInSystemModule2.js b/tests/baselines/reference/aliasesInSystemModule2.js index 0256d03a179..32d663a11e1 100644 --- a/tests/baselines/reference/aliasesInSystemModule2.js +++ b/tests/baselines/reference/aliasesInSystemModule2.js @@ -21,8 +21,8 @@ System.register(["foo"], function(exports_1) { var cls, cls2, x, y, z, M; return { setters:[ - function (_foo_1) { - foo_1 = _foo_1; + function (foo_1_1) { + foo_1 = foo_1_1; }], execute: function() { cls = foo_1.alias.Class; diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index 7d653f34bf9..5fe5c92a5b3 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. Types of property 'x' are incompatible. Type 'U' is not assignable to type 'string'. + Type 'String' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== @@ -17,5 +18,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'string'. +!!! error TS2415: Type 'String' is not assignable to type 'string'. x: U; } \ No newline at end of file diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 208646dc101..2c5e611de68 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe let blah = arguments[Symbol.iterator]; >blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7)) >arguments : Symbol(arguments) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 9b05aff5ac6..20f36e5c459 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -294,8 +294,8 @@ module EmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -313,8 +313,8 @@ module EmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -332,8 +332,8 @@ module EmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -639,7 +639,7 @@ module NonEmptyTypes { >x : number >y : base >base : base ->[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >7 : number @@ -658,7 +658,7 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >true : boolean @@ -697,8 +697,8 @@ module NonEmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -716,8 +716,8 @@ module NonEmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -735,8 +735,8 @@ module NonEmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -769,29 +769,29 @@ module NonEmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : (base | base2 | iface)[] ->[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[] +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : (base2 | base | iface)[] ->[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[] +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : (base | iface | base2)[] ->[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[] +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] >baseObj : base >ifaceObj : iface >base2Obj : base2 var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : (iface | base | base2)[] ->[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[] +>b4 : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] >ifaceObj : iface >baseObj : base >base2Obj : base2 diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 5b5a1be6b8a..1bbb6c41e8a 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[] >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : (((x: Object) => number) | ((x: string) => number))[] ->[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[] +>ds : ((x: Object) => number)[] +>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >2 : number var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : (((x: string) => number) | ((x: Object) => number))[] ->[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[] +>es : ((x: string) => number)[] +>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string >2 : number diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index faf0b130738..fd31800e840 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index b7224fe91c4..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -77,8 +77,8 @@ var myDerivedList: DerivedList; >DerivedList : DerivedList var as = [list, myDerivedList]; // List[] ->as : (List | DerivedList)[] ->[list, myDerivedList] : (List | DerivedList)[] +>as : List[] +>[list, myDerivedList] : List[] >list : List >myDerivedList : DerivedList diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt deleted file mode 100644 index 499d6bca387..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ==== - // valid uses of arrays of function types - - var x = [() => 1, () => { }]; - var r2 = x[0](); - - class C { - foo: string; - } - var y = [C, C]; - var r3 = new y[0](); - - var a: { (x: number): number; (x: string): string; }; - var b: { (x: number): number; (x: string): string; }; - var c: { (x: number): number; (x: any): any; }; - var z = [a, b, c]; - var r4 = z[0]; - var r5 = r4(''); // any not string - ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - var r5b = r4(1); - - var a2: { (x: T): number; (x: string): string;}; - var b2: { (x: T): number; (x: string): string; }; - var c2: { (x: number): number; (x: T): any; }; - - var z2 = [a2, b2, c2]; - var r6 = z2[0]; - var r7 = r6(''); // any not string - ~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.symbols b/tests/baselines/reference/arrayOfFunctionTypes3.symbols new file mode 100644 index 00000000000..d26effeb5b7 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.symbols @@ -0,0 +1,93 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +var r2 = x[0](); +>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +class C { +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + + foo: string; +>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9)) +} +var y = [C, C]; +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + +var r3 = new y[0](); +>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3)) +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) + +var a: { (x: number): number; (x: string): string; }; +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31)) + +var b: { (x: number): number; (x: string): string; }; +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31)) + +var c: { (x: number): number; (x: any): any; }; +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31)) + +var z = [a, b, c]; +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) + +var r4 = z[0]; +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) + +var r5 = r4(''); // any not string +>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var r5b = r4(1); +>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var a2: { (x: T): number; (x: string): string;}; +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30)) + +var b2: { (x: T): number; (x: string): string; }; +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30)) + +var c2: { (x: number): number; (x: T): any; }; +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) + +var z2 = [a2, b2, c2]; +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) + +var r6 = z2[0]; +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) + +var r7 = r6(''); // any not string +>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3)) +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) + diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types new file mode 100644 index 00000000000..0ed92991ed0 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : (() => void)[] +>[() => 1, () => { }] : (() => void)[] +>() => 1 : () => number +>1 : number +>() => { } : () => void + +var r2 = x[0](); +>r2 : void +>x[0]() : void +>x[0] : () => void +>x : (() => void)[] +>0 : number + +class C { +>C : C + + foo: string; +>foo : string +} +var y = [C, C]; +>y : typeof C[] +>[C, C] : typeof C[] +>C : typeof C +>C : typeof C + +var r3 = new y[0](); +>r3 : C +>new y[0]() : C +>y[0] : typeof C +>y : typeof C[] +>0 : number + +var a: { (x: number): number; (x: string): string; }; +>a : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var b: { (x: number): number; (x: string): string; }; +>b : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var c: { (x: number): number; (x: any): any; }; +>c : { (x: number): number; (x: any): any; } +>x : number +>x : any + +var z = [a, b, c]; +>z : { (x: number): number; (x: any): any; }[] +>[a, b, c] : { (x: number): number; (x: any): any; }[] +>a : { (x: number): number; (x: string): string; } +>b : { (x: number): number; (x: string): string; } +>c : { (x: number): number; (x: any): any; } + +var r4 = z[0]; +>r4 : { (x: number): number; (x: any): any; } +>z[0] : { (x: number): number; (x: any): any; } +>z : { (x: number): number; (x: any): any; }[] +>0 : number + +var r5 = r4(''); // any not string +>r5 : any +>r4('') : any +>r4 : { (x: number): number; (x: any): any; } +>'' : string + +var r5b = r4(1); +>r5b : number +>r4(1) : number +>r4 : { (x: number): number; (x: any): any; } +>1 : number + +var a2: { (x: T): number; (x: string): string;}; +>a2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var b2: { (x: T): number; (x: string): string; }; +>b2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var c2: { (x: number): number; (x: T): any; }; +>c2 : { (x: number): number; (x: T): any; } +>x : number +>T : T +>x : T +>T : T + +var z2 = [a2, b2, c2]; +>z2 : { (x: number): number; (x: T): any; }[] +>[a2, b2, c2] : { (x: number): number; (x: T): any; }[] +>a2 : { (x: T): number; (x: string): string; } +>b2 : { (x: T): number; (x: string): string; } +>c2 : { (x: number): number; (x: T): any; } + +var r6 = z2[0]; +>r6 : { (x: number): number; (x: T): any; } +>z2[0] : { (x: number): number; (x: T): any; } +>z2 : { (x: number): number; (x: T): any; }[] +>0 : number + +var r7 = r6(''); // any not string +>r7 : any +>r6('') : any +>r6 : { (x: number): number; (x: T): any; } +>'' : string + diff --git a/tests/baselines/reference/assignmentCompat1.errors.txt b/tests/baselines/reference/assignmentCompat1.errors.txt index 6734e6fc964..edb8d28eecc 100644 --- a/tests/baselines/reference/assignmentCompat1.errors.txt +++ b/tests/baselines/reference/assignmentCompat1.errors.txt @@ -1,18 +1,21 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'. Property 'one' is missing in type '{ [index: string]: any; }'. -tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'. - Index signature is missing in type '{ one: number; }'. +tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. + Property 'one' is missing in type '{ [index: number]: any; }'. ==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ==== - var x = {one: 1}; - var y: {[index:string]: any}; - - x = y; + var x = { one: 1 }; + var y: { [index: string]: any }; + var z: { [index: number]: any }; + x = y; // Error ~ !!! error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'. !!! error TS2322: Property 'one' is missing in type '{ [index: string]: any; }'. - y = x; + y = x; // Ok because index signature type is any + x = z; // Error ~ -!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'. -!!! error TS2322: Index signature is missing in type '{ one: number; }'. \ No newline at end of file +!!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. +!!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'. + z = x; // Ok because index signature type is any + \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompat1.js b/tests/baselines/reference/assignmentCompat1.js index 09546b7165e..740a44cced4 100644 --- a/tests/baselines/reference/assignmentCompat1.js +++ b/tests/baselines/reference/assignmentCompat1.js @@ -1,12 +1,18 @@ //// [assignmentCompat1.ts] -var x = {one: 1}; -var y: {[index:string]: any}; - -x = y; -y = x; +var x = { one: 1 }; +var y: { [index: string]: any }; +var z: { [index: number]: any }; +x = y; // Error +y = x; // Ok because index signature type is any +x = z; // Error +z = x; // Ok because index signature type is any + //// [assignmentCompat1.js] var x = { one: 1 }; var y; -x = y; -y = x; +var z; +x = y; // Error +y = x; // Ok because index signature type is any +x = z; // Error +z = x; // Ok because index signature type is any diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt index 0a9b50ff0b8..c5987a93ddf 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt @@ -12,12 +12,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. + Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. + Type 'Base' is not assignable to type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts (6 errors) ==== @@ -72,6 +74,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived'. var b2: { [x: number]: Derived2; } a = b2; // error @@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. var b3: { [x: number]: T; } a = b3; // ok diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt index b15f2f7905d..f91d0dd0c15 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt @@ -12,12 +12,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. + Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. + Type 'Base' is not assignable to type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts (6 errors) ==== @@ -72,6 +74,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived'. var b2: { [x: number]: Derived2; } a = b2; // error @@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. var b3: { [x: number]: T; } a = b3; // ok diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt index f002c70e90b..51762bb9418 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt @@ -18,12 +18,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. + Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. + Type 'Base' is not assignable to type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts (8 errors) ==== @@ -100,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived'. var b4: { [x: string]: Derived2; }; a3 = b4; // error @@ -112,5 +115,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt index c322364280e..0b0d70d01bb 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt @@ -18,12 +18,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived'. + Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. Index signatures are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. + Type 'Base' is not assignable to type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts (8 errors) ==== @@ -100,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived'. var b4: { [x: string]: Derived2; }; a3 = b4; // error @@ -112,5 +115,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt index a31b2ef3025..4b4c03678d7 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts(21,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. Type 'T' is not assignable to type 'string'. + Type 'Derived' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts (3 errors) ==== @@ -39,5 +40,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'string'. +!!! error TS2322: Type 'Derived' is not assignable to type 'string'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability36.errors.txt b/tests/baselines/reference/assignmentCompatability36.errors.txt deleted file mode 100644 index 591dc072fab..00000000000 --- a/tests/baselines/reference/assignmentCompatability36.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: string]: any; }'. - Index signature is missing in type 'interfaceWithPublicAndOptional'. - - -==== tests/cases/compiler/assignmentCompatability36.ts (1 errors) ==== - module __test1__ { - export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; - export var __val__obj4 = obj4; - } - module __test2__ { - export var aa:{[index:string]:any;};; - export var __val__aa = aa; - } - __test2__.__val__aa = __test1__.__val__obj4 - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: string]: any; }'. -!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability36.symbols b/tests/baselines/reference/assignmentCompatability36.symbols new file mode 100644 index 00000000000..4b4b7d75a51 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability36.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability36.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54)) +>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52)) +>two : Symbol(two, Decl(assignmentCompatability36.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability36.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1)) + + export var aa:{[index:string]:any;};; +>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14)) +>index : Symbol(index, Decl(assignmentCompatability36.ts, 5, 20)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability36.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability36.types b/tests/baselines/reference/assignmentCompatability36.types new file mode 100644 index 00000000000..b67be38e2b4 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability36.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability36.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : number + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{[index:string]:any;};; +>aa : { [index: string]: any; } +>index : string + + export var __val__aa = aa; +>__val__aa : { [index: string]: any; } +>aa : { [index: string]: any; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { [index: string]: any; } +>__test2__ : typeof __test2__ +>__val__aa : { [index: string]: any; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentNonObjectTypeConstraints.js b/tests/baselines/reference/assignmentNonObjectTypeConstraints.js new file mode 100644 index 00000000000..c9d3cec38f6 --- /dev/null +++ b/tests/baselines/reference/assignmentNonObjectTypeConstraints.js @@ -0,0 +1,42 @@ +//// [assignmentNonObjectTypeConstraints.ts] +const enum E { A, B, C } + +function foo(x: T) { + var y: number = x; // Ok +} + +foo(5); +foo(E.A); + +class A { a } +class B { b } + +function bar(x: T) { + var y: A | B = x; // Ok +} + +bar(new A); +bar(new B); + + +//// [assignmentNonObjectTypeConstraints.js] +function foo(x) { + var y = x; // Ok +} +foo(5); +foo(0 /* A */); +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +function bar(x) { + var y = x; // Ok +} +bar(new A); +bar(new B); diff --git a/tests/baselines/reference/assignmentNonObjectTypeConstraints.symbols b/tests/baselines/reference/assignmentNonObjectTypeConstraints.symbols new file mode 100644 index 00000000000..d8bff5df5f2 --- /dev/null +++ b/tests/baselines/reference/assignmentNonObjectTypeConstraints.symbols @@ -0,0 +1,58 @@ +=== tests/cases/compiler/assignmentNonObjectTypeConstraints.ts === +const enum E { A, B, C } +>E : Symbol(E, Decl(assignmentNonObjectTypeConstraints.ts, 0, 0)) +>A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14)) +>B : Symbol(E.B, Decl(assignmentNonObjectTypeConstraints.ts, 0, 17)) +>C : Symbol(E.C, Decl(assignmentNonObjectTypeConstraints.ts, 0, 20)) + +function foo(x: T) { +>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24)) +>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 2, 13)) +>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 2, 31)) +>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 2, 13)) + + var y: number = x; // Ok +>y : Symbol(y, Decl(assignmentNonObjectTypeConstraints.ts, 3, 7)) +>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 2, 31)) +} + +foo(5); +>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24)) + +foo(E.A); +>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24)) +>E.A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14)) +>E : Symbol(E, Decl(assignmentNonObjectTypeConstraints.ts, 0, 0)) +>A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14)) + +class A { a } +>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9)) +>a : Symbol(a, Decl(assignmentNonObjectTypeConstraints.ts, 9, 9)) + +class B { b } +>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13)) +>b : Symbol(b, Decl(assignmentNonObjectTypeConstraints.ts, 10, 9)) + +function bar(x: T) { +>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13)) +>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 12, 13)) +>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9)) +>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13)) +>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 12, 30)) +>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 12, 13)) + + var y: A | B = x; // Ok +>y : Symbol(y, Decl(assignmentNonObjectTypeConstraints.ts, 13, 7)) +>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9)) +>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13)) +>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 12, 30)) +} + +bar(new A); +>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13)) +>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9)) + +bar(new B); +>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13)) +>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13)) + diff --git a/tests/baselines/reference/assignmentNonObjectTypeConstraints.types b/tests/baselines/reference/assignmentNonObjectTypeConstraints.types new file mode 100644 index 00000000000..94391e2ea5f --- /dev/null +++ b/tests/baselines/reference/assignmentNonObjectTypeConstraints.types @@ -0,0 +1,65 @@ +=== tests/cases/compiler/assignmentNonObjectTypeConstraints.ts === +const enum E { A, B, C } +>E : E +>A : E +>B : E +>C : E + +function foo(x: T) { +>foo : (x: T) => void +>T : T +>x : T +>T : T + + var y: number = x; // Ok +>y : number +>x : T +} + +foo(5); +>foo(5) : void +>foo : (x: T) => void +>5 : number + +foo(E.A); +>foo(E.A) : void +>foo : (x: T) => void +>E.A : E +>E : typeof E +>A : E + +class A { a } +>A : A +>a : any + +class B { b } +>B : B +>b : any + +function bar(x: T) { +>bar : (x: T) => void +>T : T +>A : A +>B : B +>x : T +>T : T + + var y: A | B = x; // Ok +>y : A | B +>A : A +>B : B +>x : T +} + +bar(new A); +>bar(new A) : void +>bar : (x: T) => void +>new A : A +>A : typeof A + +bar(new B); +>bar(new B) : void +>bar : (x: T) => void +>new B : B +>B : typeof B + diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index cb2c5255486..0da7c4433b3 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) }; diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 8d4b98a20a1..6f492b07d1b 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index 889614387d7..f7574402c80 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index 626b820e312..97dc419ba47 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index c71592c0463..35e4394c82d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 6a72f1b1506..b91d8bf9492 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p || a; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index f81a146f943..60127a06b90 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p && a; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index 479b3b30650..83f006bc285 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,11 +4,11 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p + a; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 5d15c754793..38e9ccfe608 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = await p, a; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index bc1e2f19310..161d697b75b 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var o: { a: boolean; }; diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 7e28d92cd9c..8c6494d34af 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index 305a4c77aa3..db8cff67f01 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 715c125bcf0..e2b0e8a9137 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index 98a995d8117..75067422152 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = (await pfn)(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index 30df9c8d022..d9c9cb9ed9a 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index ac1cca1c16f..ee9779e68e8 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(await p, a, a); diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index b48e99ddec1..51ce2db20a2 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = o.fn(a, await p, a); diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 4dd9d500347..be3a841cce1 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) "before"; var b = (await po).fn(a, a, a); diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 933d46cc802..1191004a32b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -46,8 +46,8 @@ var r = true ? 1 : 2; >2 : number var r3 = true ? 1 : {}; ->r3 : number | {} ->true ? 1 : {} : number | {} +>r3 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -67,8 +67,8 @@ var r5 = true ? b : a; // typeof b >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void ->r6 : ((x: number) => void) | ((x: Object) => void) ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>r6 : (x: number) => void +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >Object : Object var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void ->r8 : ((x: Object) => void) | ((x: number) => void) ->true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void) +>r8 : (x: Object) => void +>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void >true : boolean >(x: Object) => { } : (x: Object) => void >x : Object @@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >derived2 : Derived2 var r11 = true ? base : derived2; ->r11 : Base | Derived2 ->true ? base : derived2 : Base | Derived2 +>r11 : Base +>true ? base : derived2 : Base >true : boolean >base : Base >derived2 : Derived2 diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types index 4c47753a90d..df40291b0e5 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types @@ -27,43 +27,43 @@ var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; ->b1 : (X | Y | Z)[] ->[x, y, z] : (X | Y | Z)[] +>b1 : X[] +>[x, y, z] : X[] >x : X >y : Y >z : Z var b2 = [x, z, y]; ->b2 : (X | Z | Y)[] ->[x, z, y] : (X | Z | Y)[] +>b2 : X[] +>[x, z, y] : X[] >x : X >z : Z >y : Y var b3 = [y, x, z]; ->b3 : (Y | X | Z)[] ->[y, x, z] : (Y | X | Z)[] +>b3 : X[] +>[y, x, z] : X[] >y : Y >x : X >z : Z var b4 = [y, z, x]; ->b4 : (Y | Z | X)[] ->[y, z, x] : (Y | Z | X)[] +>b4 : X[] +>[y, z, x] : X[] >y : Y >z : Z >x : X var b5 = [z, x, y]; ->b5 : (Z | X | Y)[] ->[z, x, y] : (Z | X | Y)[] +>b5 : X[] +>[z, x, y] : X[] >z : Z >x : X >y : Y var b6 = [z, y, x]; ->b6 : (Z | Y | X)[] ->[z, y, x] : (Z | Y | X)[] +>b6 : X[] +>[z, y, x] : X[] >z : Z >y : Y >x : X diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 0e236821020..8e84f48948f 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 4009, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt new file mode 100644 index 00000000000..c6c242396d8 --- /dev/null +++ b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts(7,1): error TS2322: Type 'typeof A' is not assignable to type 'new () => A'. + Cannot assign an abstract constructor type to a non-abstract constructor type. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts(8,1): error TS2322: Type 'string' is not assignable to type 'new () => A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts (2 errors) ==== + abstract class A { } + + // var AA: typeof A; + var AAA: new() => A; + + // AA = A; // okay + AAA = A; // error. + ~~~ +!!! error TS2322: Type 'typeof A' is not assignable to type 'new () => A'. +!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. + AAA = "asdf"; + ~~~ +!!! error TS2322: Type 'string' is not assignable to type 'new () => A'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.js b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.js new file mode 100644 index 00000000000..3d8fd404afc --- /dev/null +++ b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.js @@ -0,0 +1,21 @@ +//// [classAbstractAssignabilityConstructorFunction.ts] +abstract class A { } + +// var AA: typeof A; +var AAA: new() => A; + +// AA = A; // okay +AAA = A; // error. +AAA = "asdf"; + +//// [classAbstractAssignabilityConstructorFunction.js] +var A = (function () { + function A() { + } + return A; +})(); +// var AA: typeof A; +var AAA; +// AA = A; // okay +AAA = A; // error. +AAA = "asdf"; diff --git a/tests/baselines/reference/classExtendsNull.errors.txt b/tests/baselines/reference/classExtendsNull.errors.txt new file mode 100644 index 00000000000..7bb44774826 --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/classExtendsNull.ts(2,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null' + + +==== tests/cases/compiler/classExtendsNull.ts (1 errors) ==== + class C extends null { + constructor() { + ~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~ + return Object.create(null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null' + } + + class D extends null { + constructor() { + return Object.create(null); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsNull.js b/tests/baselines/reference/classExtendsNull.js new file mode 100644 index 00000000000..5627f10dca6 --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.js @@ -0,0 +1,35 @@ +//// [classExtendsNull.ts] +class C extends null { + constructor() { + super(); + return Object.create(null); + } +} + +class D extends null { + constructor() { + return Object.create(null); + } +} + +//// [classExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.call(this); + return Object.create(null); + } + return C; +})(null); +var D = (function (_super) { + __extends(D, _super); + function D() { + return Object.create(null); + } + return D; +})(null); diff --git a/tests/baselines/reference/commentInMethodCall.js b/tests/baselines/reference/commentInMethodCall.js index 4ad2fc552d7..4cbd4824a82 100644 --- a/tests/baselines/reference/commentInMethodCall.js +++ b/tests/baselines/reference/commentInMethodCall.js @@ -8,4 +8,5 @@ s.map(// do something //// [commentInMethodCall.js] //commment here var s; -s.map(function () { }); +s.map(// do something +function () { }); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.js b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js new file mode 100644 index 00000000000..4e6d693c5c2 --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js @@ -0,0 +1,32 @@ +//// [commentsArgumentsOfCallExpression1.ts] +function foo(/*c1*/ x: any) { } +foo(/*c2*/ 1); +foo(/*c3*/ function () { }); +foo( + /*c4*/ + () => { }); +foo( + /*c5*/ + /*c6*/ + () => { }); +foo(/*c7*/ + () => { }); +foo( + /*c7*/ + /*c8*/() => { }); + +//// [commentsArgumentsOfCallExpression1.js] +function foo(/*c1*/ x) { } +foo(/*c2*/ 1); +foo(/*c3*/ function () { }); +foo( +/*c4*/ +function () { }); +foo( +/*c5*/ +/*c6*/ +function () { }); +foo(/*c7*/ function () { }); +foo( +/*c7*/ +/*c8*/ function () { }); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.symbols b/tests/baselines/reference/commentsArgumentsOfCallExpression1.symbols new file mode 100644 index 00000000000..9d8495f948c --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/commentsArgumentsOfCallExpression1.ts === +function foo(/*c1*/ x: any) { } +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) +>x : Symbol(x, Decl(commentsArgumentsOfCallExpression1.ts, 0, 13)) + +foo(/*c2*/ 1); +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + +foo(/*c3*/ function () { }); +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + +foo( +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + + /*c4*/ + () => { }); +foo( +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + + /*c5*/ + /*c6*/ + () => { }); +foo(/*c7*/ +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + + () => { }); +foo( +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression1.ts, 0, 0)) + + /*c7*/ + /*c8*/() => { }); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.types b/tests/baselines/reference/commentsArgumentsOfCallExpression1.types new file mode 100644 index 00000000000..bcab3e3de36 --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/commentsArgumentsOfCallExpression1.ts === +function foo(/*c1*/ x: any) { } +>foo : (x: any) => void +>x : any + +foo(/*c2*/ 1); +>foo(/*c2*/ 1) : void +>foo : (x: any) => void +>1 : number + +foo(/*c3*/ function () { }); +>foo(/*c3*/ function () { }) : void +>foo : (x: any) => void +>function () { } : () => void + +foo( +>foo( /*c4*/ () => { }) : void +>foo : (x: any) => void + + /*c4*/ + () => { }); +>() => { } : () => void + +foo( +>foo( /*c5*/ /*c6*/ () => { }) : void +>foo : (x: any) => void + + /*c5*/ + /*c6*/ + () => { }); +>() => { } : () => void + +foo(/*c7*/ +>foo(/*c7*/ () => { }) : void +>foo : (x: any) => void + + () => { }); +>() => { } : () => void + +foo( +>foo( /*c7*/ /*c8*/() => { }) : void +>foo : (x: any) => void + + /*c7*/ + /*c8*/() => { }); +>() => { } : () => void + diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js new file mode 100644 index 00000000000..a7065410ff4 --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js @@ -0,0 +1,23 @@ +//// [commentsArgumentsOfCallExpression2.ts] +function foo(/*c1*/ x: any, /*d1*/ y: any,/*e1*/w?: any) { } +var a, b: any; +foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); +foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); +foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); +foo( + /*c4*/ function () { }, + /*d4*/() => { }, + /*e4*/ + /*e5*/ "hello"); + +//// [commentsArgumentsOfCallExpression2.js] +function foo(/*c1*/ x, /*d1*/ y, /*e1*/ w) { } +var a, b; +foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); +foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + b); +foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b)); +foo( +/*c4*/ function () { }, +/*d4*/ function () { }, +/*e4*/ +/*e5*/ "hello"); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.symbols b/tests/baselines/reference/commentsArgumentsOfCallExpression2.symbols new file mode 100644 index 00000000000..59047dd46c3 --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/commentsArgumentsOfCallExpression2.ts === +function foo(/*c1*/ x: any, /*d1*/ y: any,/*e1*/w?: any) { } +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression2.ts, 0, 0)) +>x : Symbol(x, Decl(commentsArgumentsOfCallExpression2.ts, 0, 13)) +>y : Symbol(y, Decl(commentsArgumentsOfCallExpression2.ts, 0, 27)) +>w : Symbol(w, Decl(commentsArgumentsOfCallExpression2.ts, 0, 42)) + +var a, b: any; +>a : Symbol(a, Decl(commentsArgumentsOfCallExpression2.ts, 1, 3)) +>b : Symbol(b, Decl(commentsArgumentsOfCallExpression2.ts, 1, 6)) + +foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression2.ts, 0, 0)) +>a : Symbol(a, Decl(commentsArgumentsOfCallExpression2.ts, 1, 3)) +>b : Symbol(b, Decl(commentsArgumentsOfCallExpression2.ts, 1, 6)) + +foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression2.ts, 0, 0)) +>a : Symbol(a, Decl(commentsArgumentsOfCallExpression2.ts, 1, 3)) +>b : Symbol(b, Decl(commentsArgumentsOfCallExpression2.ts, 1, 6)) + +foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression2.ts, 0, 0)) +>a : Symbol(a, Decl(commentsArgumentsOfCallExpression2.ts, 1, 3)) +>b : Symbol(b, Decl(commentsArgumentsOfCallExpression2.ts, 1, 6)) + +foo( +>foo : Symbol(foo, Decl(commentsArgumentsOfCallExpression2.ts, 0, 0)) + + /*c4*/ function () { }, + /*d4*/() => { }, + /*e4*/ + /*e5*/ "hello"); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.types b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types new file mode 100644 index 00000000000..f0a10077e66 --- /dev/null +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/commentsArgumentsOfCallExpression2.ts === +function foo(/*c1*/ x: any, /*d1*/ y: any,/*e1*/w?: any) { } +>foo : (x: any, y: any, w?: any) => void +>x : any +>y : any +>w : any + +var a, b: any; +>a : any +>b : any + +foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); +>foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b) : void +>foo : (x: any, y: any, w?: any) => void +>1 : number +>1 + 2 : number +>1 : number +>2 : number +>a + b : any +>a : any +>b : any + +foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); +>foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b) : void +>foo : (x: any, y: any, w?: any) => void +>function () { } : () => void +>() => { } : () => void +>a + /*e3*/ b : any +>a : any +>b : any + +foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); +>foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)) : void +>foo : (x: any, y: any, w?: any) => void +>function () { } : () => void +>() => { } : () => void +>(a + b) : any +>a + b : any +>a : any +>b : any + +foo( +>foo( /*c4*/ function () { }, /*d4*/() => { }, /*e4*/ /*e5*/ "hello") : void +>foo : (x: any, y: any, w?: any) => void + + /*c4*/ function () { }, +>function () { } : () => void + + /*d4*/() => { }, +>() => { } : () => void + + /*e4*/ + /*e5*/ "hello"); +>"hello" : string + diff --git a/tests/baselines/reference/commentsBeforeFunctionExpression1.js b/tests/baselines/reference/commentsBeforeFunctionExpression1.js index 0e23722faf3..5b250b9c064 100644 --- a/tests/baselines/reference/commentsBeforeFunctionExpression1.js +++ b/tests/baselines/reference/commentsBeforeFunctionExpression1.js @@ -6,5 +6,5 @@ var v = { //// [commentsBeforeFunctionExpression1.js] var v = { - f: function (a) { return 0; } + f: /**own f*/ function (a) { return 0; } }; diff --git a/tests/baselines/reference/commentsInterface.js b/tests/baselines/reference/commentsInterface.js index bff79a02aa5..3deac9871f1 100644 --- a/tests/baselines/reference/commentsInterface.js +++ b/tests/baselines/reference/commentsInterface.js @@ -89,7 +89,7 @@ var i2_i_nc_fnfoo = i2_i.nc_fnfoo; var i2_i_nc_fnfoo_r = i2_i.nc_fnfoo(10); var i3_i; i3_i = { - f: function (/**i3_i a*/ a) { return "Hello" + a; }, + f: /**own f*/ function (/**i3_i a*/ a) { return "Hello" + a; }, l: this.f, /** own x*/ x: this.f(10), diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js new file mode 100644 index 00000000000..fa7790443ac --- /dev/null +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js @@ -0,0 +1,29 @@ +//// [commentsOnPropertyOfObjectLiteral1.ts] +var resolve = { + id: /*! @ngInject */ (details: any) => details.id, + id1: /* c1 */ "hello", + id2: + /*! @ngInject */ (details: any) => details.id, + id3: + /*! @ngInject */ + (details: any) => details.id, + id4: + /*! @ngInject */ + /* C2 */ + (details: any) => details.id, +}; + +//// [commentsOnPropertyOfObjectLiteral1.js] +var resolve = { + id: /*! @ngInject */ function (details) { return details.id; }, + id1: /* c1 */ "hello", + id2: + /*! @ngInject */ function (details) { return details.id; }, + id3: + /*! @ngInject */ + function (details) { return details.id; }, + id4: + /*! @ngInject */ + /* C2 */ + function (details) { return details.id; } +}; diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.symbols b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.symbols new file mode 100644 index 00000000000..b48c1fb982c --- /dev/null +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/commentsOnPropertyOfObjectLiteral1.ts === +var resolve = { +>resolve : Symbol(resolve, Decl(commentsOnPropertyOfObjectLiteral1.ts, 0, 3)) + + id: /*! @ngInject */ (details: any) => details.id, +>id : Symbol(id, Decl(commentsOnPropertyOfObjectLiteral1.ts, 0, 15)) +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 1, 26)) +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 1, 26)) + + id1: /* c1 */ "hello", +>id1 : Symbol(id1, Decl(commentsOnPropertyOfObjectLiteral1.ts, 1, 54)) + + id2: +>id2 : Symbol(id2, Decl(commentsOnPropertyOfObjectLiteral1.ts, 2, 26)) + + /*! @ngInject */ (details: any) => details.id, +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 4, 26)) +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 4, 26)) + + id3: +>id3 : Symbol(id3, Decl(commentsOnPropertyOfObjectLiteral1.ts, 4, 54)) + + /*! @ngInject */ + (details: any) => details.id, +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 7, 5)) +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 7, 5)) + + id4: +>id4 : Symbol(id4, Decl(commentsOnPropertyOfObjectLiteral1.ts, 7, 33)) + + /*! @ngInject */ + /* C2 */ + (details: any) => details.id, +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 11, 5)) +>details : Symbol(details, Decl(commentsOnPropertyOfObjectLiteral1.ts, 11, 5)) + +}; diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types new file mode 100644 index 00000000000..93ce87558d8 --- /dev/null +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types @@ -0,0 +1,51 @@ +=== tests/cases/compiler/commentsOnPropertyOfObjectLiteral1.ts === +var resolve = { +>resolve : { id: (details: any) => any; id1: string; id2: (details: any) => any; id3: (details: any) => any; id4: (details: any) => any; } +>{ id: /*! @ngInject */ (details: any) => details.id, id1: /* c1 */ "hello", id2: /*! @ngInject */ (details: any) => details.id, id3: /*! @ngInject */ (details: any) => details.id, id4: /*! @ngInject */ /* C2 */ (details: any) => details.id,} : { id: (details: any) => any; id1: string; id2: (details: any) => any; id3: (details: any) => any; id4: (details: any) => any; } + + id: /*! @ngInject */ (details: any) => details.id, +>id : (details: any) => any +>(details: any) => details.id : (details: any) => any +>details : any +>details.id : any +>details : any +>id : any + + id1: /* c1 */ "hello", +>id1 : string +>"hello" : string + + id2: +>id2 : (details: any) => any + + /*! @ngInject */ (details: any) => details.id, +>(details: any) => details.id : (details: any) => any +>details : any +>details.id : any +>details : any +>id : any + + id3: +>id3 : (details: any) => any + + /*! @ngInject */ + (details: any) => details.id, +>(details: any) => details.id : (details: any) => any +>details : any +>details.id : any +>details : any +>id : any + + id4: +>id4 : (details: any) => any + + /*! @ngInject */ + /* C2 */ + (details: any) => details.id, +>(details: any) => details.id : (details: any) => any +>details : any +>details.id : any +>details : any +>id : any + +}; diff --git a/tests/baselines/reference/commonjsSafeImport.js b/tests/baselines/reference/commonjsSafeImport.js new file mode 100644 index 00000000000..a0ef81cc277 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/commonjsSafeImport.ts] //// + +//// [10_lib.ts] + +export function Foo() {} + +//// [main.ts] +import { Foo } from './10_lib'; + +Foo(); + + +//// [10_lib.js] +function Foo() { } +exports.Foo = Foo; +//// [main.js] +var _10_lib_1 = require('./10_lib'); +_10_lib_1.Foo(); + + +//// [10_lib.d.ts] +export declare function Foo(): void; +//// [main.d.ts] diff --git a/tests/baselines/reference/commonjsSafeImport.symbols b/tests/baselines/reference/commonjsSafeImport.symbols new file mode 100644 index 00000000000..45e247b46a0 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : Symbol(Foo, Decl(10_lib.ts, 0, 0)) + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + +Foo(); +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/commonjsSafeImport.types b/tests/baselines/reference/commonjsSafeImport.types new file mode 100644 index 00000000000..5a4dded5b1f --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : () => void + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : () => void + +Foo(); +>Foo() : void +>Foo : () => void + diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index d36428a0379..696204ae8da 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":["[\"hello\"]"],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC;QACLA,QAAQA,CAACA;IACbA,CAACA;;CACJ,CAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":["[\"hello\"]"],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC,GAAT;QACIA,QAAQA,CAACA;IACbA,CAACA;;CACJ,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index 74d69f566a0..c922e4f706d 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -28,26 +28,28 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 2 > ^^^ 3 > ^^^^^^^ 4 > ^ -5 > ^^^-> +5 > ^^^ 1->{ > 2 > [ 3 > "hello" 4 > ] +5 > 1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) 2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0) 3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0) 4 >Emitted(2, 16) Source(2, 14) + SourceIndex(0) +5 >Emitted(2, 19) Source(2, 5) + SourceIndex(0) --- >>> debugger; -1->^^^^^^^^ +1 >^^^^^^^^ 2 > ^^^^^^^^ 3 > ^ -1->() { +1 >["hello"]() { > 2 > debugger 3 > ; -1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (["hello"]) +1 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (["hello"]) 2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (["hello"]) 3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (["hello"]) --- diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index d5530f98fe8..026c8f42272 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -31,21 +31,21 @@ var b: B; //Cond ? Expr1 : Expr2, Expr1 is supertype //Be Not contextually typed true ? x : a; ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A var result1 = true ? x : a; ->result1 : X | A ->true ? x : a : X | A +>result1 : X +>true ? x : a : X >true : boolean >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; ->true ? {} : 1 : {} | number +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -63,8 +63,8 @@ true ? { a: 1 } : { a: 2, b: 'string' }; >'string' : string var result2 = true ? {} : 1; ->result2 : {} | number ->true ? {} : 1 : {} | number +>result2 : {} +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number) +>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any >true : boolean >(m) => m.propertyX : (m: A) => any >m : A @@ -111,21 +111,21 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Cond ? Expr1 : Expr2, Expr2 is supertype //Be Not contextually typed true ? a : x; ->true ? a : x : A | X +>true ? a : x : X >true : boolean >a : A >x : X var result5 = true ? a : x; ->result5 : A | X ->true ? a : x : A | X +>result5 : X +>true ? a : x : X >true : boolean >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; ->true ? 1 : {} : number | {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -143,8 +143,8 @@ true ? { a: 2, b: 'string' } : { a: 1 }; >1 : number var result6 = true ? 1 : {}; ->result6 : number | {} ->true ? 1 : {} : number | {} +>result6 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any) +>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any >true : boolean >(m) => m.propertyA : (m: A) => number >m : A diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index be7dad54eeb..586652d41eb 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal. @@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member // forward reference to the element of the same enum X = Y, ~ -!!! error TS2474: In 'const' enum declarations member initializer must be constant expression. +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. // forward reference to the element of the same enum Y = E1.Z, ~~~~ diff --git a/tests/baselines/reference/constEnumToStringNoComments.js b/tests/baselines/reference/constEnumToStringNoComments.js new file mode 100644 index 00000000000..a23be26033e --- /dev/null +++ b/tests/baselines/reference/constEnumToStringNoComments.js @@ -0,0 +1,37 @@ +//// [constEnumToStringNoComments.ts] +const enum Foo { + X = 100, + Y = 0.5, + Z = 2., + A = -1, + B = -1.5, + C = -1. +} + +let x0 = Foo.X.toString(); +let x1 = Foo["X"].toString(); +let y0 = Foo.Y.toString(); +let y1 = Foo["Y"].toString(); +let z0 = Foo.Z.toString(); +let z1 = Foo["Z"].toString(); +let a0 = Foo.A.toString(); +let a1 = Foo["A"].toString(); +let b0 = Foo.B.toString(); +let b1 = Foo["B"].toString(); +let c0 = Foo.C.toString(); +let c1 = Foo["C"].toString(); + + +//// [constEnumToStringNoComments.js] +var x0 = 100 .toString(); +var x1 = 100 .toString(); +var y0 = 0.5.toString(); +var y1 = 0.5.toString(); +var z0 = 2 .toString(); +var z1 = 2 .toString(); +var a0 = -1 .toString(); +var a1 = -1 .toString(); +var b0 = -1.5.toString(); +var b1 = -1.5.toString(); +var c0 = -1 .toString(); +var c1 = -1 .toString(); diff --git a/tests/baselines/reference/constEnumToStringNoComments.symbols b/tests/baselines/reference/constEnumToStringNoComments.symbols new file mode 100644 index 00000000000..0206e6a5d90 --- /dev/null +++ b/tests/baselines/reference/constEnumToStringNoComments.symbols @@ -0,0 +1,113 @@ +=== tests/cases/compiler/constEnumToStringNoComments.ts === +const enum Foo { +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) + + X = 100, +>X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16)) + + Y = 0.5, +>Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12)) + + Z = 2., +>Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12)) + + A = -1, +>A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11)) + + B = -1.5, +>B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11)) + + C = -1. +>C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13)) +} + +let x0 = Foo.X.toString(); +>x0 : Symbol(x0, Decl(constEnumToStringNoComments.ts, 9, 3)) +>Foo.X.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let x1 = Foo["X"].toString(); +>x1 : Symbol(x1, Decl(constEnumToStringNoComments.ts, 10, 3)) +>Foo["X"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"X" : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let y0 = Foo.Y.toString(); +>y0 : Symbol(y0, Decl(constEnumToStringNoComments.ts, 11, 3)) +>Foo.Y.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let y1 = Foo["Y"].toString(); +>y1 : Symbol(y1, Decl(constEnumToStringNoComments.ts, 12, 3)) +>Foo["Y"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"Y" : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let z0 = Foo.Z.toString(); +>z0 : Symbol(z0, Decl(constEnumToStringNoComments.ts, 13, 3)) +>Foo.Z.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let z1 = Foo["Z"].toString(); +>z1 : Symbol(z1, Decl(constEnumToStringNoComments.ts, 14, 3)) +>Foo["Z"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"Z" : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let a0 = Foo.A.toString(); +>a0 : Symbol(a0, Decl(constEnumToStringNoComments.ts, 15, 3)) +>Foo.A.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let a1 = Foo["A"].toString(); +>a1 : Symbol(a1, Decl(constEnumToStringNoComments.ts, 16, 3)) +>Foo["A"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"A" : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let b0 = Foo.B.toString(); +>b0 : Symbol(b0, Decl(constEnumToStringNoComments.ts, 17, 3)) +>Foo.B.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let b1 = Foo["B"].toString(); +>b1 : Symbol(b1, Decl(constEnumToStringNoComments.ts, 18, 3)) +>Foo["B"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"B" : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let c0 = Foo.C.toString(); +>c0 : Symbol(c0, Decl(constEnumToStringNoComments.ts, 19, 3)) +>Foo.C.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let c1 = Foo["C"].toString(); +>c1 : Symbol(c1, Decl(constEnumToStringNoComments.ts, 20, 3)) +>Foo["C"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0)) +>"C" : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + diff --git a/tests/baselines/reference/constEnumToStringNoComments.types b/tests/baselines/reference/constEnumToStringNoComments.types new file mode 100644 index 00000000000..21c4dc6c703 --- /dev/null +++ b/tests/baselines/reference/constEnumToStringNoComments.types @@ -0,0 +1,140 @@ +=== tests/cases/compiler/constEnumToStringNoComments.ts === +const enum Foo { +>Foo : Foo + + X = 100, +>X : Foo +>100 : number + + Y = 0.5, +>Y : Foo +>0.5 : number + + Z = 2., +>Z : Foo +>2. : number + + A = -1, +>A : Foo +>-1 : number +>1 : number + + B = -1.5, +>B : Foo +>-1.5 : number +>1.5 : number + + C = -1. +>C : Foo +>-1. : number +>1. : number +} + +let x0 = Foo.X.toString(); +>x0 : string +>Foo.X.toString() : string +>Foo.X.toString : (radix?: number) => string +>Foo.X : Foo +>Foo : typeof Foo +>X : Foo +>toString : (radix?: number) => string + +let x1 = Foo["X"].toString(); +>x1 : string +>Foo["X"].toString() : string +>Foo["X"].toString : (radix?: number) => string +>Foo["X"] : Foo +>Foo : typeof Foo +>"X" : string +>toString : (radix?: number) => string + +let y0 = Foo.Y.toString(); +>y0 : string +>Foo.Y.toString() : string +>Foo.Y.toString : (radix?: number) => string +>Foo.Y : Foo +>Foo : typeof Foo +>Y : Foo +>toString : (radix?: number) => string + +let y1 = Foo["Y"].toString(); +>y1 : string +>Foo["Y"].toString() : string +>Foo["Y"].toString : (radix?: number) => string +>Foo["Y"] : Foo +>Foo : typeof Foo +>"Y" : string +>toString : (radix?: number) => string + +let z0 = Foo.Z.toString(); +>z0 : string +>Foo.Z.toString() : string +>Foo.Z.toString : (radix?: number) => string +>Foo.Z : Foo +>Foo : typeof Foo +>Z : Foo +>toString : (radix?: number) => string + +let z1 = Foo["Z"].toString(); +>z1 : string +>Foo["Z"].toString() : string +>Foo["Z"].toString : (radix?: number) => string +>Foo["Z"] : Foo +>Foo : typeof Foo +>"Z" : string +>toString : (radix?: number) => string + +let a0 = Foo.A.toString(); +>a0 : string +>Foo.A.toString() : string +>Foo.A.toString : (radix?: number) => string +>Foo.A : Foo +>Foo : typeof Foo +>A : Foo +>toString : (radix?: number) => string + +let a1 = Foo["A"].toString(); +>a1 : string +>Foo["A"].toString() : string +>Foo["A"].toString : (radix?: number) => string +>Foo["A"] : Foo +>Foo : typeof Foo +>"A" : string +>toString : (radix?: number) => string + +let b0 = Foo.B.toString(); +>b0 : string +>Foo.B.toString() : string +>Foo.B.toString : (radix?: number) => string +>Foo.B : Foo +>Foo : typeof Foo +>B : Foo +>toString : (radix?: number) => string + +let b1 = Foo["B"].toString(); +>b1 : string +>Foo["B"].toString() : string +>Foo["B"].toString : (radix?: number) => string +>Foo["B"] : Foo +>Foo : typeof Foo +>"B" : string +>toString : (radix?: number) => string + +let c0 = Foo.C.toString(); +>c0 : string +>Foo.C.toString() : string +>Foo.C.toString : (radix?: number) => string +>Foo.C : Foo +>Foo : typeof Foo +>C : Foo +>toString : (radix?: number) => string + +let c1 = Foo["C"].toString(); +>c1 : string +>Foo["C"].toString() : string +>Foo["C"].toString : (radix?: number) => string +>Foo["C"] : Foo +>Foo : typeof Foo +>"C" : string +>toString : (radix?: number) => string + diff --git a/tests/baselines/reference/constEnumToStringWithComments.js b/tests/baselines/reference/constEnumToStringWithComments.js new file mode 100644 index 00000000000..e70833c9b89 --- /dev/null +++ b/tests/baselines/reference/constEnumToStringWithComments.js @@ -0,0 +1,37 @@ +//// [constEnumToStringWithComments.ts] +const enum Foo { + X = 100, + Y = 0.5, + Z = 2., + A = -1, + B = -1.5, + C = -1. +} + +let x0 = Foo.X.toString(); +let x1 = Foo["X"].toString(); +let y0 = Foo.Y.toString(); +let y1 = Foo["Y"].toString(); +let z0 = Foo.Z.toString(); +let z1 = Foo["Z"].toString(); +let a0 = Foo.A.toString(); +let a1 = Foo["A"].toString(); +let b0 = Foo.B.toString(); +let b1 = Foo["B"].toString(); +let c0 = Foo.C.toString(); +let c1 = Foo["C"].toString(); + + +//// [constEnumToStringWithComments.js] +var x0 = 100 /* X */ .toString(); +var x1 = 100 /* "X" */ .toString(); +var y0 = 0.5 /* Y */.toString(); +var y1 = 0.5 /* "Y" */.toString(); +var z0 = 2 /* Z */ .toString(); +var z1 = 2 /* "Z" */ .toString(); +var a0 = -1 /* A */ .toString(); +var a1 = -1 /* "A" */ .toString(); +var b0 = -1.5 /* B */.toString(); +var b1 = -1.5 /* "B" */.toString(); +var c0 = -1 /* C */ .toString(); +var c1 = -1 /* "C" */ .toString(); diff --git a/tests/baselines/reference/constEnumToStringWithComments.symbols b/tests/baselines/reference/constEnumToStringWithComments.symbols new file mode 100644 index 00000000000..fafb7ab4611 --- /dev/null +++ b/tests/baselines/reference/constEnumToStringWithComments.symbols @@ -0,0 +1,113 @@ +=== tests/cases/compiler/constEnumToStringWithComments.ts === +const enum Foo { +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) + + X = 100, +>X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16)) + + Y = 0.5, +>Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12)) + + Z = 2., +>Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12)) + + A = -1, +>A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11)) + + B = -1.5, +>B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11)) + + C = -1. +>C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13)) +} + +let x0 = Foo.X.toString(); +>x0 : Symbol(x0, Decl(constEnumToStringWithComments.ts, 9, 3)) +>Foo.X.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let x1 = Foo["X"].toString(); +>x1 : Symbol(x1, Decl(constEnumToStringWithComments.ts, 10, 3)) +>Foo["X"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"X" : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let y0 = Foo.Y.toString(); +>y0 : Symbol(y0, Decl(constEnumToStringWithComments.ts, 11, 3)) +>Foo.Y.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let y1 = Foo["Y"].toString(); +>y1 : Symbol(y1, Decl(constEnumToStringWithComments.ts, 12, 3)) +>Foo["Y"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"Y" : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let z0 = Foo.Z.toString(); +>z0 : Symbol(z0, Decl(constEnumToStringWithComments.ts, 13, 3)) +>Foo.Z.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let z1 = Foo["Z"].toString(); +>z1 : Symbol(z1, Decl(constEnumToStringWithComments.ts, 14, 3)) +>Foo["Z"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"Z" : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let a0 = Foo.A.toString(); +>a0 : Symbol(a0, Decl(constEnumToStringWithComments.ts, 15, 3)) +>Foo.A.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let a1 = Foo["A"].toString(); +>a1 : Symbol(a1, Decl(constEnumToStringWithComments.ts, 16, 3)) +>Foo["A"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"A" : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let b0 = Foo.B.toString(); +>b0 : Symbol(b0, Decl(constEnumToStringWithComments.ts, 17, 3)) +>Foo.B.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let b1 = Foo["B"].toString(); +>b1 : Symbol(b1, Decl(constEnumToStringWithComments.ts, 18, 3)) +>Foo["B"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"B" : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let c0 = Foo.C.toString(); +>c0 : Symbol(c0, Decl(constEnumToStringWithComments.ts, 19, 3)) +>Foo.C.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo.C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + +let c1 = Foo["C"].toString(); +>c1 : Symbol(c1, Decl(constEnumToStringWithComments.ts, 20, 3)) +>Foo["C"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0)) +>"C" : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + diff --git a/tests/baselines/reference/constEnumToStringWithComments.types b/tests/baselines/reference/constEnumToStringWithComments.types new file mode 100644 index 00000000000..72d7d367f5d --- /dev/null +++ b/tests/baselines/reference/constEnumToStringWithComments.types @@ -0,0 +1,140 @@ +=== tests/cases/compiler/constEnumToStringWithComments.ts === +const enum Foo { +>Foo : Foo + + X = 100, +>X : Foo +>100 : number + + Y = 0.5, +>Y : Foo +>0.5 : number + + Z = 2., +>Z : Foo +>2. : number + + A = -1, +>A : Foo +>-1 : number +>1 : number + + B = -1.5, +>B : Foo +>-1.5 : number +>1.5 : number + + C = -1. +>C : Foo +>-1. : number +>1. : number +} + +let x0 = Foo.X.toString(); +>x0 : string +>Foo.X.toString() : string +>Foo.X.toString : (radix?: number) => string +>Foo.X : Foo +>Foo : typeof Foo +>X : Foo +>toString : (radix?: number) => string + +let x1 = Foo["X"].toString(); +>x1 : string +>Foo["X"].toString() : string +>Foo["X"].toString : (radix?: number) => string +>Foo["X"] : Foo +>Foo : typeof Foo +>"X" : string +>toString : (radix?: number) => string + +let y0 = Foo.Y.toString(); +>y0 : string +>Foo.Y.toString() : string +>Foo.Y.toString : (radix?: number) => string +>Foo.Y : Foo +>Foo : typeof Foo +>Y : Foo +>toString : (radix?: number) => string + +let y1 = Foo["Y"].toString(); +>y1 : string +>Foo["Y"].toString() : string +>Foo["Y"].toString : (radix?: number) => string +>Foo["Y"] : Foo +>Foo : typeof Foo +>"Y" : string +>toString : (radix?: number) => string + +let z0 = Foo.Z.toString(); +>z0 : string +>Foo.Z.toString() : string +>Foo.Z.toString : (radix?: number) => string +>Foo.Z : Foo +>Foo : typeof Foo +>Z : Foo +>toString : (radix?: number) => string + +let z1 = Foo["Z"].toString(); +>z1 : string +>Foo["Z"].toString() : string +>Foo["Z"].toString : (radix?: number) => string +>Foo["Z"] : Foo +>Foo : typeof Foo +>"Z" : string +>toString : (radix?: number) => string + +let a0 = Foo.A.toString(); +>a0 : string +>Foo.A.toString() : string +>Foo.A.toString : (radix?: number) => string +>Foo.A : Foo +>Foo : typeof Foo +>A : Foo +>toString : (radix?: number) => string + +let a1 = Foo["A"].toString(); +>a1 : string +>Foo["A"].toString() : string +>Foo["A"].toString : (radix?: number) => string +>Foo["A"] : Foo +>Foo : typeof Foo +>"A" : string +>toString : (radix?: number) => string + +let b0 = Foo.B.toString(); +>b0 : string +>Foo.B.toString() : string +>Foo.B.toString : (radix?: number) => string +>Foo.B : Foo +>Foo : typeof Foo +>B : Foo +>toString : (radix?: number) => string + +let b1 = Foo["B"].toString(); +>b1 : string +>Foo["B"].toString() : string +>Foo["B"].toString : (radix?: number) => string +>Foo["B"] : Foo +>Foo : typeof Foo +>"B" : string +>toString : (radix?: number) => string + +let c0 = Foo.C.toString(); +>c0 : string +>Foo.C.toString() : string +>Foo.C.toString : (radix?: number) => string +>Foo.C : Foo +>Foo : typeof Foo +>C : Foo +>toString : (radix?: number) => string + +let c1 = Foo["C"].toString(); +>c1 : string +>Foo["C"].toString() : string +>Foo["C"].toString : (radix?: number) => string +>Foo["C"] : Foo +>Foo : typeof Foo +>"C" : string +>toString : (radix?: number) => string + diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols index 172336603ab..3e23a7812f5 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols @@ -82,5 +82,7 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1)) >IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types index 02dfecf5c08..8e1915d4754 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types @@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >x4 : IWithCallSignatures | IWithCallSignatures4 >IWithCallSignatures : IWithCallSignatures >IWithCallSignatures4 : IWithCallSignatures4 ->a => /*here a should be any*/ a.toString() : (a: any) => any ->a : any ->a.toString() : any ->a.toString : any ->a : any ->toString : any +>a => /*here a should be any*/ a.toString() : (a: number) => string +>a : number +>a.toString() : string +>a.toString : (radix?: number) => string +>a : number +>toString : (radix?: number) => string diff --git a/tests/baselines/reference/contextualTyping.js.map b/tests/baselines/reference/contextualTyping.js.map index fc84d1dc318..7c814c231e0 100644 --- a/tests/baselines/reference/contextualTyping.js.map +++ b/tests/baselines/reference/contextualTyping.js.map @@ -1,2 +1,2 @@ //// [contextualTyping.js.map] -{"version":3,"file":"contextualTyping.js","sourceRoot":"","sources":["contextualTyping.ts"],"names":["C1T5","C1T5.constructor","C2T5","C4T5","C4T5.constructor","C5T5","c9t5","C11t5","C11t5.constructor","EF1","Point"],"mappings":"AAaA,AADA,sCAAsC;;IACtCA;QACIC,QAAGA,GAAqCA,UAASA,CAACA;YAC9C,MAAM,CAAC,CAAC,CAAC;QACb,CAAC,CAAAA;IACLA,CAACA;IAADD,WAACA;AAADA,CAACA,AAJD,IAIC;AAGD,AADA,uCAAuC;AACvC,IAAO,IAAI,CAIV;AAJD,WAAO,IAAI,EAAC,CAAC;IACEE,QAAGA,GAAqCA,UAASA,CAACA;QACzD,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,CAAAA;AACLA,CAACA,EAJM,IAAI,KAAJ,IAAI,QAIV;AAGD,AADA,gCAAgC;IAC5B,IAAI,GAA0B,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAC7D,IAAI,IAAI,GAAS,CAAC;IACd,CAAC,EAAE,CAAC;CACP,CAAC,CAAA;AACF,IAAI,IAAI,GAAa,EAAE,CAAC;AACxB,IAAI,IAAI,GAAe,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AACxD,IAAI,IAAI,GAAwB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAClE,IAAI,IAAI,GAAmC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAChF,IAAI,IAAI,GAGJ,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9B,IAAI,IAAI,GAAqC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,IAAI,IAAI,GAAe,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AAC/B,IAAI,KAAK,GAAW,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5C,IAAI,KAAK,GAAwC,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,IAAI,KAAK,GAAS;IACd,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,IAAI,KAAK,GAAS,CAAC;IACf,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,IAAI,KAAK,GAAS,CAAC;IACf,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AAGF,AADA,qCAAqC;;IAGjCC;QACIC,IAAIA,CAACA,GAAGA,GAAGA,UAASA,CAACA,EAAEA,CAACA;YACpB,MAAM,CAAC,CAAC,CAAC;QACb,CAAC,CAAAA;IACLA,CAACA;IACLD,WAACA;AAADA,CAACA,AAPD,IAOC;AAGD,AADA,sCAAsC;AACtC,IAAO,IAAI,CAKV;AALD,WAAO,IAAI,EAAC,CAAC;IAETE,QAAGA,GAAGA,UAASA,CAACA,EAAEA,CAACA;QACf,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,CAAAA;AACLA,CAACA,EALM,IAAI,KAAJ,IAAI,QAKV;AAGD,AADA,+BAA+B;IAC3B,IAAyB,CAAC;AAC9B,IAAI,GAAwB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAG9D,AADA,kCAAkC;IAC9B,IAAY,CAAC;AACjB,IAAI,CAAC,CAAC,CAAC,GAAS,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;AAuBzB,IAAI,KAAK,GAkBS,CAAC,EAAE,CAAC,CAAC;AAEvB,KAAK,CAAC,EAAE,GAAG,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AACtC,KAAK,CAAC,EAAE,GAAS,CAAC;IACd,CAAC,EAAE,CAAC;CACP,CAAC,CAAC;AACH,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;AACd,KAAK,CAAC,EAAE,GAAG,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC5C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC7C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAChD,KAAK,CAAC,EAAE,GAAG,UAAS,CAAS,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAE5C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AACnB,KAAK,CAAC,GAAG,GAAG,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,KAAK,CAAC,GAAG,GAAG,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,KAAK,CAAC,GAAG,GAAG;IACR,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,KAAK,CAAC,GAAG,GAAS,CAAC;IACf,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,KAAK,CAAC,GAAG,GAAS,CAAC;IACf,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AAEF,AADA,yBAAyB;cACX,CAAsB,IAAGC,CAACA;AAAA,CAAC;AACzC,IAAI,CAAC,UAAS,CAAC;IACX,MAAM,CAAO,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC;AAGH,AADA,4BAA4B;IACxB,KAAK,GAA8B,cAAa,MAAM,CAAC,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAG/F,AADA,0BAA0B;;IACZC,eAAYA,CAAsBA;IAAIC,CAACA;IAACD,YAACA;AAADA,CAACA,AAAvD,IAAuD;AAAA,CAAC;AACxD,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAGrD,AADA,qCAAqC;IACjC,KAAK,GAA2B,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAC/D,IAAI,KAAK,GAAU,CAAC;IAChB,CAAC,EAAE,CAAC;CACP,CAAC,CAAC;AACH,IAAI,KAAK,GAAc,EAAE,CAAC;AAC1B,IAAI,KAAK,GAAgB,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC1D,IAAI,KAAK,GAAyB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AACpE,IAAI,KAAK,GAAoC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAClF,IAAI,KAAK,GAGN,UAAS,CAAQ,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAEnC,IAAI,KAAK,GAAsC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,IAAI,KAAK,GAAgB,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AACjC,IAAI,MAAM,GAAY,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAyC,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,IAAI,MAAM,GAAU;IAChB,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,IAAI,MAAM,GAAU,CAAC;IACjB,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,IAAI,MAAM,GAAU,CAAC;IACjB,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AAOF,aAAa,CAAC,EAAC,CAAC,IAAIE,MAAMA,CAACA,CAACA,GAACA,CAACA,CAACA,CAACA,CAACA;AAEjC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;AAcnB,eAAe,CAAC,EAAE,CAAC;IACfC,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA;IACXA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA;IAEXA,MAAMA,CAACA,IAAIA,CAACA;AAChBA,CAACA;AAED,KAAK,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/B,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,EAAE,EAAE,EAAE;IACjC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,GAAG;IACd,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,GAAG,EAAE,UAAS,EAAE,EAAE,EAAE;QAChB,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/C,CAAC;CACJ,CAAC;AAIF,IAAI,CAAC,GAAM,EAAG,CAAC"} \ No newline at end of file +{"version":3,"file":"contextualTyping.js","sourceRoot":"","sources":["contextualTyping.ts"],"names":["C1T5","C1T5.constructor","C2T5","C4T5","C4T5.constructor","C5T5","c9t5","C11t5","C11t5.constructor","EF1","Point"],"mappings":"AAYA,sCAAsC;AACtC;IAAAA;QACIC,QAAGA,GAAqCA,UAASA,CAACA;YAC9C,MAAM,CAAC,CAAC,CAAC;QACb,CAAC,CAAAA;IACLA,CAACA;IAADD,WAACA;AAADA,CAACA,AAJD,IAIC;AAED,uCAAuC;AACvC,IAAO,IAAI,CAIV;AAJD,WAAO,IAAI,EAAC,CAAC;IACEE,QAAGA,GAAqCA,UAASA,CAACA;QACzD,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,CAAAA;AACLA,CAACA,EAJM,IAAI,KAAJ,IAAI,QAIV;AAED,gCAAgC;AAChC,IAAI,IAAI,GAA0B,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAC7D,IAAI,IAAI,GAAS,CAAC;IACd,CAAC,EAAE,CAAC;CACP,CAAC,CAAA;AACF,IAAI,IAAI,GAAa,EAAE,CAAC;AACxB,IAAI,IAAI,GAAe,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AACxD,IAAI,IAAI,GAAwB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAClE,IAAI,IAAI,GAAmC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAChF,IAAI,IAAI,GAGJ,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9B,IAAI,IAAI,GAAqC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,IAAI,IAAI,GAAe,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AAC/B,IAAI,KAAK,GAAW,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5C,IAAI,KAAK,GAAwC,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,IAAI,KAAK,GAAS;IACd,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,IAAI,KAAK,GAAS,CAAC;IACf,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,IAAI,KAAK,GAAS,CAAC;IACf,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AAEF,qCAAqC;AACrC;IAEIC;QACIC,IAAIA,CAACA,GAAGA,GAAGA,UAASA,CAACA,EAAEA,CAACA;YACpB,MAAM,CAAC,CAAC,CAAC;QACb,CAAC,CAAAA;IACLA,CAACA;IACLD,WAACA;AAADA,CAACA,AAPD,IAOC;AAED,sCAAsC;AACtC,IAAO,IAAI,CAKV;AALD,WAAO,IAAI,EAAC,CAAC;IAETE,QAAGA,GAAGA,UAASA,CAACA,EAAEA,CAACA;QACf,MAAM,CAAC,CAAC,CAAC;IACb,CAAC,CAAAA;AACLA,CAACA,EALM,IAAI,KAAJ,IAAI,QAKV;AAED,+BAA+B;AAC/B,IAAI,IAAyB,CAAC;AAC9B,IAAI,GAAwB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAE9D,kCAAkC;AAClC,IAAI,IAAY,CAAC;AACjB,IAAI,CAAC,CAAC,CAAC,GAAS,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;AAuBzB,IAAI,KAAK,GAkBS,CAAC,EAAE,CAAC,CAAC;AAEvB,KAAK,CAAC,EAAE,GAAG,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AACtC,KAAK,CAAC,EAAE,GAAS,CAAC;IACd,CAAC,EAAE,CAAC;CACP,CAAC,CAAC;AACH,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;AACd,KAAK,CAAC,EAAE,GAAG,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC5C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC7C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAChD,KAAK,CAAC,EAAE,GAAG,UAAS,CAAS,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAE5C,KAAK,CAAC,EAAE,GAAG,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AACnB,KAAK,CAAC,GAAG,GAAG,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,KAAK,CAAC,GAAG,GAAG,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,KAAK,CAAC,GAAG,GAAG;IACR,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,KAAK,CAAC,GAAG,GAAS,CAAC;IACf,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,KAAK,CAAC,GAAG,GAAS,CAAC;IACf,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AACF,yBAAyB;AACzB,cAAc,CAAsB,IAAGC,CAACA;AAAA,CAAC;AACzC,IAAI,CAAC,UAAS,CAAC;IACX,MAAM,CAAO,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC;AAEH,4BAA4B;AAC5B,IAAI,KAAK,GAA8B,cAAa,MAAM,CAAC,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAE/F,0BAA0B;AAC1B;IAAcC,eAAYA,CAAsBA;IAAIC,CAACA;IAACD,YAACA;AAADA,CAACA,AAAvD,IAAuD;AAAA,CAAC;AACxD,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAErD,qCAAqC;AACrC,IAAI,KAAK,GAA2B,CAAC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAC/D,IAAI,KAAK,GAAU,CAAC;IAChB,CAAC,EAAE,CAAC;CACP,CAAC,CAAC;AACH,IAAI,KAAK,GAAc,EAAE,CAAC;AAC1B,IAAI,KAAK,GAAgB,cAAa,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAC1D,IAAI,KAAK,GAAyB,UAAS,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AACpE,IAAI,KAAK,GAAoC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC;AAClF,IAAI,KAAK,GAGN,UAAS,CAAQ,IAAI,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC;AAEnC,IAAI,KAAK,GAAsC,UAAS,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,IAAI,KAAK,GAAgB,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;AACjC,IAAI,MAAM,GAAY,CAAO,CAAC,EAAE,CAAC,EAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAyC,CAAC,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,IAAI,MAAM,GAAU;IAChB,GAAG,EAAQ,CAAC,EAAE,CAAC;CAClB,CAAA;AACD,IAAI,MAAM,GAAU,CAAC;IACjB,CAAC,EAAE,UAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AACF,IAAI,MAAM,GAAU,CAAC;IACjB,CAAC,EAAE,EAAE;CACR,CAAC,CAAA;AAOF,aAAa,CAAC,EAAC,CAAC,IAAIE,MAAMA,CAACA,CAACA,GAACA,CAACA,CAACA,CAACA,CAACA;AAEjC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;AAcnB,eAAe,CAAC,EAAE,CAAC;IACfC,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA;IACXA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA;IAEXA,MAAMA,CAACA,IAAIA,CAACA;AAChBA,CAACA;AAED,KAAK,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/B,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,EAAE,EAAE,EAAE;IACjC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,GAAG;IACd,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,GAAG,EAAE,UAAS,EAAE,EAAE,EAAE;QAChB,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/C,CAAC;CACJ,CAAC;AAIF,IAAI,CAAC,GAAM,EAAG,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping.sourcemap.txt b/tests/baselines/reference/contextualTyping.sourcemap.txt index b6b4c18b289..72419ef846a 100644 --- a/tests/baselines/reference/contextualTyping.sourcemap.txt +++ b/tests/baselines/reference/contextualTyping.sourcemap.txt @@ -10,8 +10,7 @@ sourceFile:contextualTyping.ts ------------------------------------------------------------------- >>>// CONTEXT: Class property declaration 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 >// DEFAULT INTERFACES >interface IFoo { > n: number; @@ -24,21 +23,23 @@ sourceFile:contextualTyping.ts > foo: IFoo; >} > - >// CONTEXT: Class property declaration > -2 > -3 >// CONTEXT: Class property declaration -1 >Emitted(1, 1) Source(14, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(13, 1) + SourceIndex(0) -3 >Emitted(1, 39) Source(13, 39) + SourceIndex(0) +2 >// CONTEXT: Class property declaration +1 >Emitted(1, 1) Source(13, 1) + SourceIndex(0) +2 >Emitted(1, 39) Source(13, 39) + SourceIndex(0) --- >>>var C1T5 = (function () { ->>> function C1T5() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(3, 5) Source(14, 1) + SourceIndex(0) name (C1T5) +1 >Emitted(2, 1) Source(14, 1) + SourceIndex(0) +--- +>>> function C1T5() { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(3, 5) Source(14, 1) + SourceIndex(0) name (C1T5) --- >>> this.foo = function (i) { 1->^^^^^^^^ @@ -127,17 +128,13 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Module property declaration 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - >// CONTEXT: Module property declaration > -2 > -3 >// CONTEXT: Module property declaration -1->Emitted(10, 1) Source(21, 1) + SourceIndex(0) -2 >Emitted(10, 1) Source(20, 1) + SourceIndex(0) -3 >Emitted(10, 40) Source(20, 40) + SourceIndex(0) +2 >// CONTEXT: Module property declaration +1->Emitted(10, 1) Source(20, 1) + SourceIndex(0) +2 >Emitted(10, 40) Source(20, 40) + SourceIndex(0) --- >>>var C2T5; 1 > @@ -257,66 +254,65 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Variable declaration 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^-> 1-> > - >// CONTEXT: Variable declaration > -2 > -3 >// CONTEXT: Variable declaration -1->Emitted(17, 1) Source(28, 1) + SourceIndex(0) -2 >Emitted(17, 1) Source(27, 1) + SourceIndex(0) -3 >Emitted(17, 33) Source(27, 33) + SourceIndex(0) +2 >// CONTEXT: Variable declaration +1->Emitted(17, 1) Source(27, 1) + SourceIndex(0) +2 >Emitted(17, 33) Source(27, 33) + SourceIndex(0) --- >>>var c3t1 = (function (s) { return s; }); -1->^^^^ -2 > ^^^^ -3 > ^^^ -4 > ^ -5 > ^^^^^^^^^^ -6 > ^ -7 > ^^^^ -8 > ^^^^^^ -9 > ^ -10> ^ -11> ^ -12> ^ -13> ^ -14> ^ -15> ^ +1-> +2 >^^^^ +3 > ^^^^ +4 > ^^^ +5 > ^ +6 > ^^^^^^^^^^ +7 > ^ +8 > ^^^^ +9 > ^^^^^^ +10> ^ +11> ^ +12> ^ +13> ^ +14> ^ +15> ^ +16> ^ 1-> - >var -2 > c3t1 -3 > : (s: string) => string = -4 > ( -5 > function( -6 > s -7 > ) { -8 > return -9 > -10> s -11> -12> -13> } -14> ) -15> ; -1->Emitted(18, 5) Source(28, 5) + SourceIndex(0) -2 >Emitted(18, 9) Source(28, 9) + SourceIndex(0) -3 >Emitted(18, 12) Source(28, 35) + SourceIndex(0) -4 >Emitted(18, 13) Source(28, 36) + SourceIndex(0) -5 >Emitted(18, 23) Source(28, 45) + SourceIndex(0) -6 >Emitted(18, 24) Source(28, 46) + SourceIndex(0) -7 >Emitted(18, 28) Source(28, 50) + SourceIndex(0) -8 >Emitted(18, 34) Source(28, 56) + SourceIndex(0) -9 >Emitted(18, 35) Source(28, 57) + SourceIndex(0) -10>Emitted(18, 36) Source(28, 58) + SourceIndex(0) -11>Emitted(18, 37) Source(28, 58) + SourceIndex(0) -12>Emitted(18, 38) Source(28, 59) + SourceIndex(0) -13>Emitted(18, 39) Source(28, 60) + SourceIndex(0) -14>Emitted(18, 40) Source(28, 61) + SourceIndex(0) -15>Emitted(18, 41) Source(28, 62) + SourceIndex(0) + > +2 >var +3 > c3t1 +4 > : (s: string) => string = +5 > ( +6 > function( +7 > s +8 > ) { +9 > return +10> +11> s +12> +13> +14> } +15> ) +16> ; +1->Emitted(18, 1) Source(28, 1) + SourceIndex(0) +2 >Emitted(18, 5) Source(28, 5) + SourceIndex(0) +3 >Emitted(18, 9) Source(28, 9) + SourceIndex(0) +4 >Emitted(18, 12) Source(28, 35) + SourceIndex(0) +5 >Emitted(18, 13) Source(28, 36) + SourceIndex(0) +6 >Emitted(18, 23) Source(28, 45) + SourceIndex(0) +7 >Emitted(18, 24) Source(28, 46) + SourceIndex(0) +8 >Emitted(18, 28) Source(28, 50) + SourceIndex(0) +9 >Emitted(18, 34) Source(28, 56) + SourceIndex(0) +10>Emitted(18, 35) Source(28, 57) + SourceIndex(0) +11>Emitted(18, 36) Source(28, 58) + SourceIndex(0) +12>Emitted(18, 37) Source(28, 58) + SourceIndex(0) +13>Emitted(18, 38) Source(28, 59) + SourceIndex(0) +14>Emitted(18, 39) Source(28, 60) + SourceIndex(0) +15>Emitted(18, 40) Source(28, 61) + SourceIndex(0) +16>Emitted(18, 41) Source(28, 62) + SourceIndex(0) --- >>>var c3t2 = ({ 1 > @@ -945,27 +941,28 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Class property assignment 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - >// CONTEXT: Class property assignment > -2 > -3 >// CONTEXT: Class property assignment -1->Emitted(40, 1) Source(56, 1) + SourceIndex(0) -2 >Emitted(40, 1) Source(55, 1) + SourceIndex(0) -3 >Emitted(40, 38) Source(55, 38) + SourceIndex(0) +2 >// CONTEXT: Class property assignment +1->Emitted(40, 1) Source(55, 1) + SourceIndex(0) +2 >Emitted(40, 38) Source(55, 38) + SourceIndex(0) --- >>>var C4T5 = (function () { ->>> function C4T5() { -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^-> 1 > - >class C4T5 { + > +1 >Emitted(41, 1) Source(56, 1) + SourceIndex(0) +--- +>>> function C4T5() { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->class C4T5 { > foo: (i: number, s: string) => string; > -1 >Emitted(42, 5) Source(58, 5) + SourceIndex(0) name (C4T5) +1->Emitted(42, 5) Source(58, 5) + SourceIndex(0) name (C4T5) --- >>> this.foo = function (i, s) { 1->^^^^^^^^ @@ -1070,17 +1067,13 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Module property assignment 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - >// CONTEXT: Module property assignment > -2 > -3 >// CONTEXT: Module property assignment -1->Emitted(49, 1) Source(66, 1) + SourceIndex(0) -2 >Emitted(49, 1) Source(65, 1) + SourceIndex(0) -3 >Emitted(49, 39) Source(65, 39) + SourceIndex(0) +2 >// CONTEXT: Module property assignment +1->Emitted(49, 1) Source(65, 1) + SourceIndex(0) +2 >Emitted(49, 39) Source(65, 39) + SourceIndex(0) --- >>>var C5T5; 1 > @@ -1209,30 +1202,29 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Variable assignment 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - >// CONTEXT: Variable assignment > -2 > -3 >// CONTEXT: Variable assignment -1->Emitted(56, 1) Source(74, 1) + SourceIndex(0) -2 >Emitted(56, 1) Source(73, 1) + SourceIndex(0) -3 >Emitted(56, 32) Source(73, 32) + SourceIndex(0) +2 >// CONTEXT: Variable assignment +1->Emitted(56, 1) Source(73, 1) + SourceIndex(0) +2 >Emitted(56, 32) Source(73, 32) + SourceIndex(0) --- >>>var c6t5; -1 >^^^^ -2 > ^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >^^^^ +3 > ^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - >var -2 > c6t5: (n: number) => IFoo -3 > ; -1 >Emitted(57, 5) Source(74, 5) + SourceIndex(0) -2 >Emitted(57, 9) Source(74, 30) + SourceIndex(0) -3 >Emitted(57, 10) Source(74, 31) + SourceIndex(0) + > +2 >var +3 > c6t5: (n: number) => IFoo +4 > ; +1 >Emitted(57, 1) Source(74, 1) + SourceIndex(0) +2 >Emitted(57, 5) Source(74, 5) + SourceIndex(0) +3 >Emitted(57, 9) Source(74, 30) + SourceIndex(0) +4 >Emitted(57, 10) Source(74, 31) + SourceIndex(0) --- >>>c6t5 = function (n) { return ({}); }; 1-> @@ -1284,30 +1276,29 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Array index assignment 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > > - >// CONTEXT: Array index assignment > -2 > -3 >// CONTEXT: Array index assignment -1 >Emitted(59, 1) Source(78, 1) + SourceIndex(0) -2 >Emitted(59, 1) Source(77, 1) + SourceIndex(0) -3 >Emitted(59, 35) Source(77, 35) + SourceIndex(0) +2 >// CONTEXT: Array index assignment +1 >Emitted(59, 1) Source(77, 1) + SourceIndex(0) +2 >Emitted(59, 35) Source(77, 35) + SourceIndex(0) --- >>>var c7t2; -1 >^^^^ -2 > ^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^-> +1 > +2 >^^^^ +3 > ^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^-> 1 > - >var -2 > c7t2: IFoo[] -3 > ; -1 >Emitted(60, 5) Source(78, 5) + SourceIndex(0) -2 >Emitted(60, 9) Source(78, 17) + SourceIndex(0) -3 >Emitted(60, 10) Source(78, 18) + SourceIndex(0) + > +2 >var +3 > c7t2: IFoo[] +4 > ; +1 >Emitted(60, 1) Source(78, 1) + SourceIndex(0) +2 >Emitted(60, 5) Source(78, 5) + SourceIndex(0) +3 >Emitted(60, 9) Source(78, 17) + SourceIndex(0) +4 >Emitted(60, 10) Source(78, 18) + SourceIndex(0) --- >>>c7t2[0] = ({ n: 1 }); 1-> @@ -2140,31 +2131,30 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Function call 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> - >// CONTEXT: Function call > -2 > -3 >// CONTEXT: Function call -1->Emitted(85, 1) Source(146, 1) + SourceIndex(0) -2 >Emitted(85, 1) Source(145, 1) + SourceIndex(0) -3 >Emitted(85, 26) Source(145, 26) + SourceIndex(0) +2 >// CONTEXT: Function call +1->Emitted(85, 1) Source(145, 1) + SourceIndex(0) +2 >Emitted(85, 26) Source(145, 26) + SourceIndex(0) --- >>>function c9t5(f) { } -1 >^^^^^^^^^^^^^^ -2 > ^ -3 > ^^^^ -4 > ^ +1 > +2 >^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ 1 > - >function c9t5( -2 > f: (n: number) => IFoo -3 > ) { -4 > } -1 >Emitted(86, 15) Source(146, 15) + SourceIndex(0) -2 >Emitted(86, 16) Source(146, 37) + SourceIndex(0) -3 >Emitted(86, 20) Source(146, 40) + SourceIndex(0) name (c9t5) -4 >Emitted(86, 21) Source(146, 41) + SourceIndex(0) name (c9t5) + > +2 >function c9t5( +3 > f: (n: number) => IFoo +4 > ) { +5 > } +1 >Emitted(86, 1) Source(146, 1) + SourceIndex(0) +2 >Emitted(86, 15) Source(146, 15) + SourceIndex(0) +3 >Emitted(86, 16) Source(146, 37) + SourceIndex(0) +4 >Emitted(86, 20) Source(146, 40) + SourceIndex(0) name (c9t5) +5 >Emitted(86, 21) Source(146, 41) + SourceIndex(0) name (c9t5) --- >>>; 1 > @@ -2236,107 +2226,107 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Return statement 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > - >// CONTEXT: Return statement > -2 > -3 >// CONTEXT: Return statement -1->Emitted(91, 1) Source(152, 1) + SourceIndex(0) -2 >Emitted(91, 1) Source(151, 1) + SourceIndex(0) -3 >Emitted(91, 29) Source(151, 29) + SourceIndex(0) +2 >// CONTEXT: Return statement +1->Emitted(91, 1) Source(151, 1) + SourceIndex(0) +2 >Emitted(91, 29) Source(151, 29) + SourceIndex(0) --- >>>var c10t5 = function () { return function (n) { return ({}); }; }; -1->^^^^ -2 > ^^^^^ -3 > ^^^ -4 > ^^^^^^^^^^^^^^ -5 > ^^^^^^ -6 > ^ -7 > ^^^^^^^^^^ -8 > ^ -9 > ^^^^ -10> ^^^^^^ -11> ^ -12> ^ -13> ^^ -14> ^ -15> ^ -16> ^ -17> ^ -18> ^ -19> ^ -20> ^ -21> ^ +1-> +2 >^^^^ +3 > ^^^^^ +4 > ^^^ +5 > ^^^^^^^^^^^^^^ +6 > ^^^^^^ +7 > ^ +8 > ^^^^^^^^^^ +9 > ^ +10> ^^^^ +11> ^^^^^^ +12> ^ +13> ^ +14> ^^ +15> ^ +16> ^ +17> ^ +18> ^ +19> ^ +20> ^ +21> ^ +22> ^ 1-> - >var -2 > c10t5 -3 > : () => (n: number) => IFoo = -4 > function() { -5 > return -6 > -7 > function( -8 > n -9 > ) { -10> return -11> -12> ( -13> {} -14> ) -15> -16> -17> } -18> -19> -20> } -21> ; -1->Emitted(92, 5) Source(152, 5) + SourceIndex(0) -2 >Emitted(92, 10) Source(152, 10) + SourceIndex(0) -3 >Emitted(92, 13) Source(152, 40) + SourceIndex(0) -4 >Emitted(92, 27) Source(152, 53) + SourceIndex(0) -5 >Emitted(92, 33) Source(152, 59) + SourceIndex(0) -6 >Emitted(92, 34) Source(152, 60) + SourceIndex(0) -7 >Emitted(92, 44) Source(152, 69) + SourceIndex(0) -8 >Emitted(92, 45) Source(152, 70) + SourceIndex(0) -9 >Emitted(92, 49) Source(152, 74) + SourceIndex(0) -10>Emitted(92, 55) Source(152, 80) + SourceIndex(0) -11>Emitted(92, 56) Source(152, 87) + SourceIndex(0) -12>Emitted(92, 57) Source(152, 88) + SourceIndex(0) -13>Emitted(92, 59) Source(152, 90) + SourceIndex(0) -14>Emitted(92, 60) Source(152, 91) + SourceIndex(0) -15>Emitted(92, 61) Source(152, 91) + SourceIndex(0) -16>Emitted(92, 62) Source(152, 92) + SourceIndex(0) -17>Emitted(92, 63) Source(152, 93) + SourceIndex(0) -18>Emitted(92, 64) Source(152, 93) + SourceIndex(0) -19>Emitted(92, 65) Source(152, 94) + SourceIndex(0) -20>Emitted(92, 66) Source(152, 95) + SourceIndex(0) -21>Emitted(92, 67) Source(152, 96) + SourceIndex(0) + > +2 >var +3 > c10t5 +4 > : () => (n: number) => IFoo = +5 > function() { +6 > return +7 > +8 > function( +9 > n +10> ) { +11> return +12> +13> ( +14> {} +15> ) +16> +17> +18> } +19> +20> +21> } +22> ; +1->Emitted(92, 1) Source(152, 1) + SourceIndex(0) +2 >Emitted(92, 5) Source(152, 5) + SourceIndex(0) +3 >Emitted(92, 10) Source(152, 10) + SourceIndex(0) +4 >Emitted(92, 13) Source(152, 40) + SourceIndex(0) +5 >Emitted(92, 27) Source(152, 53) + SourceIndex(0) +6 >Emitted(92, 33) Source(152, 59) + SourceIndex(0) +7 >Emitted(92, 34) Source(152, 60) + SourceIndex(0) +8 >Emitted(92, 44) Source(152, 69) + SourceIndex(0) +9 >Emitted(92, 45) Source(152, 70) + SourceIndex(0) +10>Emitted(92, 49) Source(152, 74) + SourceIndex(0) +11>Emitted(92, 55) Source(152, 80) + SourceIndex(0) +12>Emitted(92, 56) Source(152, 87) + SourceIndex(0) +13>Emitted(92, 57) Source(152, 88) + SourceIndex(0) +14>Emitted(92, 59) Source(152, 90) + SourceIndex(0) +15>Emitted(92, 60) Source(152, 91) + SourceIndex(0) +16>Emitted(92, 61) Source(152, 91) + SourceIndex(0) +17>Emitted(92, 62) Source(152, 92) + SourceIndex(0) +18>Emitted(92, 63) Source(152, 93) + SourceIndex(0) +19>Emitted(92, 64) Source(152, 93) + SourceIndex(0) +20>Emitted(92, 65) Source(152, 94) + SourceIndex(0) +21>Emitted(92, 66) Source(152, 95) + SourceIndex(0) +22>Emitted(92, 67) Source(152, 96) + SourceIndex(0) --- >>>// CONTEXT: Newing a class 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> 1 > > - >// CONTEXT: Newing a class > -2 > -3 >// CONTEXT: Newing a class -1 >Emitted(93, 1) Source(155, 1) + SourceIndex(0) -2 >Emitted(93, 1) Source(154, 1) + SourceIndex(0) -3 >Emitted(93, 27) Source(154, 27) + SourceIndex(0) +2 >// CONTEXT: Newing a class +1 >Emitted(93, 1) Source(154, 1) + SourceIndex(0) +2 >Emitted(93, 27) Source(154, 27) + SourceIndex(0) --- >>>var C11t5 = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(94, 1) Source(155, 1) + SourceIndex(0) +--- >>> function C11t5(f) { 1->^^^^ 2 > ^^^^^^^^^^^^^^^ 3 > ^ -1-> - >class C11t5 { +1->class C11t5 { 2 > constructor( 3 > f: (n: number) => IFoo 1->Emitted(95, 5) Source(155, 15) + SourceIndex(0) name (C11t5) @@ -2448,66 +2438,65 @@ sourceFile:contextualTyping.ts --- >>>// CONTEXT: Type annotated expression 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> 1 > > - >// CONTEXT: Type annotated expression > -2 > -3 >// CONTEXT: Type annotated expression -1 >Emitted(101, 1) Source(159, 1) + SourceIndex(0) -2 >Emitted(101, 1) Source(158, 1) + SourceIndex(0) -3 >Emitted(101, 38) Source(158, 38) + SourceIndex(0) +2 >// CONTEXT: Type annotated expression +1 >Emitted(101, 1) Source(158, 1) + SourceIndex(0) +2 >Emitted(101, 38) Source(158, 38) + SourceIndex(0) --- >>>var c12t1 = (function (s) { return s; }); -1->^^^^ -2 > ^^^^^ -3 > ^^^ -4 > ^ -5 > ^^^^^^^^^^ -6 > ^ -7 > ^^^^ -8 > ^^^^^^ -9 > ^ -10> ^ -11> ^ -12> ^ -13> ^ -14> ^ -15> ^ +1-> +2 >^^^^ +3 > ^^^^^ +4 > ^^^ +5 > ^ +6 > ^^^^^^^^^^ +7 > ^ +8 > ^^^^ +9 > ^^^^^^ +10> ^ +11> ^ +12> ^ +13> ^ +14> ^ +15> ^ +16> ^ 1-> - >var -2 > c12t1 -3 > = <(s: string) => string> -4 > ( -5 > function( -6 > s -7 > ) { -8 > return -9 > -10> s -11> -12> -13> } -14> ) -15> ; -1->Emitted(102, 5) Source(159, 5) + SourceIndex(0) -2 >Emitted(102, 10) Source(159, 10) + SourceIndex(0) -3 >Emitted(102, 13) Source(159, 37) + SourceIndex(0) -4 >Emitted(102, 14) Source(159, 38) + SourceIndex(0) -5 >Emitted(102, 24) Source(159, 47) + SourceIndex(0) -6 >Emitted(102, 25) Source(159, 48) + SourceIndex(0) -7 >Emitted(102, 29) Source(159, 52) + SourceIndex(0) -8 >Emitted(102, 35) Source(159, 58) + SourceIndex(0) -9 >Emitted(102, 36) Source(159, 59) + SourceIndex(0) -10>Emitted(102, 37) Source(159, 60) + SourceIndex(0) -11>Emitted(102, 38) Source(159, 60) + SourceIndex(0) -12>Emitted(102, 39) Source(159, 61) + SourceIndex(0) -13>Emitted(102, 40) Source(159, 62) + SourceIndex(0) -14>Emitted(102, 41) Source(159, 63) + SourceIndex(0) -15>Emitted(102, 42) Source(159, 64) + SourceIndex(0) + > +2 >var +3 > c12t1 +4 > = <(s: string) => string> +5 > ( +6 > function( +7 > s +8 > ) { +9 > return +10> +11> s +12> +13> +14> } +15> ) +16> ; +1->Emitted(102, 1) Source(159, 1) + SourceIndex(0) +2 >Emitted(102, 5) Source(159, 5) + SourceIndex(0) +3 >Emitted(102, 10) Source(159, 10) + SourceIndex(0) +4 >Emitted(102, 13) Source(159, 37) + SourceIndex(0) +5 >Emitted(102, 14) Source(159, 38) + SourceIndex(0) +6 >Emitted(102, 24) Source(159, 47) + SourceIndex(0) +7 >Emitted(102, 25) Source(159, 48) + SourceIndex(0) +8 >Emitted(102, 29) Source(159, 52) + SourceIndex(0) +9 >Emitted(102, 35) Source(159, 58) + SourceIndex(0) +10>Emitted(102, 36) Source(159, 59) + SourceIndex(0) +11>Emitted(102, 37) Source(159, 60) + SourceIndex(0) +12>Emitted(102, 38) Source(159, 60) + SourceIndex(0) +13>Emitted(102, 39) Source(159, 61) + SourceIndex(0) +14>Emitted(102, 40) Source(159, 62) + SourceIndex(0) +15>Emitted(102, 41) Source(159, 63) + SourceIndex(0) +16>Emitted(102, 42) Source(159, 64) + SourceIndex(0) --- >>>var c12t2 = ({ 1 > diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index 0bb61604336..d3e5b9942e3 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] +>xs : ((x: A) => void)[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/declFileClassExtendsNull.js b/tests/baselines/reference/declFileClassExtendsNull.js new file mode 100644 index 00000000000..0d50b320592 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.js @@ -0,0 +1,23 @@ +//// [declFileClassExtendsNull.ts] + +class ExtendsNull extends null { +} + +//// [declFileClassExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var ExtendsNull = (function (_super) { + __extends(ExtendsNull, _super); + function ExtendsNull() { + _super.apply(this, arguments); + } + return ExtendsNull; +})(null); + + +//// [declFileClassExtendsNull.d.ts] +declare class ExtendsNull extends null { +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.symbols b/tests/baselines/reference/declFileClassExtendsNull.symbols new file mode 100644 index 00000000000..e86276faad8 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : Symbol(ExtendsNull, Decl(declFileClassExtendsNull.ts, 0, 0)) +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.types b/tests/baselines/reference/declFileClassExtendsNull.types new file mode 100644 index 00000000000..bbd43d99c0d --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : ExtendsNull +>null : null +} diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.js b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js index 85897bc2c9d..7886736f7e4 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.js +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js @@ -20,8 +20,8 @@ function makePoint(x) { }; } ; -var point = makePoint(2); -var x = point.x; +var /*4*/ point = makePoint(2); +var /*2*/ x = point.x; point.x = 30; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js index dd39a30f7a2..8d79a576b06 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js @@ -16,8 +16,8 @@ function makePoint(x) { }; } ; -var point = makePoint(2); -var x = point.x; +var /*4*/ point = makePoint(2); +var /*2*/ x = point.x; //// [declFileObjectLiteralWithOnlyGetter.d.ts] diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js index e219e885053..f7a48fe810c 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js @@ -17,7 +17,7 @@ function makePoint(x) { }; } ; -var point = makePoint(2); +var /*3*/ point = makePoint(2); point.x = 30; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.js b/tests/baselines/reference/declarationEmit_exportAssignment.js new file mode 100644 index 00000000000..54f3eb5fd0e --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportAssignment.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/declarationEmit_exportAssignment.ts] //// + +//// [utils.ts] + +export function foo() { } +export function bar() { } +export interface Buzz { } + +//// [index.ts] +import {foo} from "utils"; +export = foo; + +//// [utils.js] +function foo() { } +exports.foo = foo; +function bar() { } +exports.bar = bar; +//// [index.js] +var utils_1 = require("utils"); +module.exports = utils_1.foo; + + +//// [utils.d.ts] +export declare function foo(): void; +export declare function bar(): void; +export interface Buzz { +} +//// [index.d.ts] +import { foo } from "utils"; +export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.symbols b/tests/baselines/reference/declarationEmit_exportAssignment.symbols new file mode 100644 index 00000000000..b443ba6e797 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportAssignment.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/utils.ts === + +export function foo() { } +>foo : Symbol(foo, Decl(utils.ts, 0, 0)) + +export function bar() { } +>bar : Symbol(bar, Decl(utils.ts, 1, 25)) + +export interface Buzz { } +>Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) + +=== tests/cases/compiler/index.ts === +import {foo} from "utils"; +>foo : Symbol(foo, Decl(index.ts, 0, 8)) + +export = foo; +>foo : Symbol(foo, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.types b/tests/baselines/reference/declarationEmit_exportAssignment.types new file mode 100644 index 00000000000..81c56da432f --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportAssignment.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/utils.ts === + +export function foo() { } +>foo : () => void + +export function bar() { } +>bar : () => void + +export interface Buzz { } +>Buzz : Buzz + +=== tests/cases/compiler/index.ts === +import {foo} from "utils"; +>foo : () => void + +export = foo; +>foo : () => void + diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.js b/tests/baselines/reference/declarationEmit_exportDeclaration.js new file mode 100644 index 00000000000..f05639dc18f --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/declarationEmit_exportDeclaration.ts] //// + +//// [utils.ts] + +export function foo() { } +export function bar() { } +export interface Buzz { } + +//// [index.ts] +import {foo, bar, Buzz} from "utils"; + +foo(); +let obj: Buzz; +export {bar}; + +//// [utils.js] +function foo() { } +exports.foo = foo; +function bar() { } +exports.bar = bar; +//// [index.js] +var utils_1 = require("utils"); +exports.bar = utils_1.bar; +utils_1.foo(); +var obj; + + +//// [utils.d.ts] +export declare function foo(): void; +export declare function bar(): void; +export interface Buzz { +} +//// [index.d.ts] +import { bar } from "utils"; +export { bar }; diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols new file mode 100644 index 00000000000..5cd8c5fee99 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/utils.ts === + +export function foo() { } +>foo : Symbol(foo, Decl(utils.ts, 0, 0)) + +export function bar() { } +>bar : Symbol(bar, Decl(utils.ts, 1, 25)) + +export interface Buzz { } +>Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) + +=== tests/cases/compiler/index.ts === +import {foo, bar, Buzz} from "utils"; +>foo : Symbol(foo, Decl(index.ts, 0, 8)) +>bar : Symbol(bar, Decl(index.ts, 0, 12)) +>Buzz : Symbol(Buzz, Decl(index.ts, 0, 17)) + +foo(); +>foo : Symbol(foo, Decl(index.ts, 0, 8)) + +let obj: Buzz; +>obj : Symbol(obj, Decl(index.ts, 3, 3)) +>Buzz : Symbol(Buzz, Decl(index.ts, 0, 17)) + +export {bar}; +>bar : Symbol(bar, Decl(index.ts, 4, 8)) + diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.types b/tests/baselines/reference/declarationEmit_exportDeclaration.types new file mode 100644 index 00000000000..058ee863c61 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/utils.ts === + +export function foo() { } +>foo : () => void + +export function bar() { } +>bar : () => void + +export interface Buzz { } +>Buzz : Buzz + +=== tests/cases/compiler/index.ts === +import {foo, bar, Buzz} from "utils"; +>foo : () => void +>bar : () => void +>Buzz : any + +foo(); +>foo() : void +>foo : () => void + +let obj: Buzz; +>obj : Buzz +>Buzz : Buzz + +export {bar}; +>bar : () => void + diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js new file mode 100644 index 00000000000..5c2ce580507 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadata.js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/decorators/decoratorMetadata.ts] //// + +//// [service.ts] +export default class Service { +} +//// [component.ts] +import Service from "./service"; + +declare var decorator: any; + +@decorator +class MyComponent { + constructor(public Service: Service) { + } +} + +//// [service.js] +var Service = (function () { + function Service() { + } + return Service; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Service; +//// [component.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); + switch (arguments.length) { + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); + } +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var service_1 = require("./service"); +var MyComponent = (function () { + function MyComponent(Service) { + this.Service = Service; + } + MyComponent = __decorate([ + decorator, + __metadata('design:paramtypes', [service_1.default]) + ], MyComponent); + return MyComponent; +})(); diff --git a/tests/baselines/reference/decoratorMetadata.symbols b/tests/baselines/reference/decoratorMetadata.symbols new file mode 100644 index 00000000000..706f5ace8a9 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadata.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/decorators/service.ts === +export default class Service { +>Service : Symbol(Service, Decl(service.ts, 0, 0)) +} +=== tests/cases/conformance/decorators/component.ts === +import Service from "./service"; +>Service : Symbol(Service, Decl(component.ts, 0, 6)) + +declare var decorator: any; +>decorator : Symbol(decorator, Decl(component.ts, 2, 11)) + +@decorator +>decorator : Symbol(decorator, Decl(component.ts, 2, 11)) + +class MyComponent { +>MyComponent : Symbol(MyComponent, Decl(component.ts, 2, 27)) + + constructor(public Service: Service) { +>Service : Symbol(Service, Decl(component.ts, 6, 16)) +>Service : Symbol(Service, Decl(component.ts, 0, 6)) + } +} diff --git a/tests/baselines/reference/decoratorMetadata.types b/tests/baselines/reference/decoratorMetadata.types new file mode 100644 index 00000000000..b0ce80fb1e4 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadata.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/decorators/service.ts === +export default class Service { +>Service : Service +} +=== tests/cases/conformance/decorators/component.ts === +import Service from "./service"; +>Service : typeof Service + +declare var decorator: any; +>decorator : any + +@decorator +>decorator : any + +class MyComponent { +>MyComponent : MyComponent + + constructor(public Service: Service) { +>Service : Service +>Service : Service + } +} diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js new file mode 100644 index 00000000000..204b1ba9a49 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js @@ -0,0 +1,31 @@ +//// [decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts] + +declare var decorator: any; + +class MyClass { + constructor(test: string, test2: number) { + + } + + @decorator + doSomething() { + + } +} + + +//// [decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js] +var MyClass = (function () { + function MyClass(test, test2) { + } + MyClass.prototype.doSomething = function () { + }; + Object.defineProperty(MyClass.prototype, "doSomething", + __decorate([ + decorator, + __metadata('design:type', Function), + __metadata('design:paramtypes', []), + __metadata('design:returntype', void 0) + ], MyClass.prototype, "doSomething", Object.getOwnPropertyDescriptor(MyClass.prototype, "doSomething"))); + return MyClass; +})(); diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.symbols b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.symbols new file mode 100644 index 00000000000..79c6fcbf24f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts === + +declare var decorator: any; +>decorator : Symbol(decorator, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 11)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 27)) + + constructor(test: string, test2: number) { +>test : Symbol(test, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 4, 16)) +>test2 : Symbol(test2, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 4, 29)) + + } + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 1, 11)) + + doSomething() { +>doSomething : Symbol(doSomething, Decl(decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts, 6, 5)) + + } +} + diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.types b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.types new file mode 100644 index 00000000000..aebd8143eab --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts === + +declare var decorator: any; +>decorator : any + +class MyClass { +>MyClass : MyClass + + constructor(test: string, test2: number) { +>test : string +>test2 : number + + } + + @decorator +>decorator : any + + doSomething() { +>doSomething : () => void + + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js new file mode 100644 index 00000000000..1523915a390 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -0,0 +1,39 @@ +//// [decoratorMetadataWithConstructorType.ts] + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} + + +//// [decoratorMetadataWithConstructorType.js] +var A = (function () { + function A() { + console.log('new A'); + } + return A; +})(); +function decorator(target, propertyKey) { +} +var B = (function () { + function B() { + this.x = new A(); + } + __decorate([ + decorator, + __metadata('design:type', A) + ], B.prototype, "x"); + return B; +})(); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols new file mode 100644 index 00000000000..57221f0d139 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) + + log(msg: string): void; +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>msg : Symbol(msg, Decl(decoratorMetadataWithConstructorType.ts, 2, 8)) + +}; + +class A { +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) + + constructor() { console.log('new A'); } +>console.log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +} + +function decorator(target: Object, propertyKey: string) { +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) +>target : Symbol(target, Decl(decoratorMetadataWithConstructorType.ts, 9, 19)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataWithConstructorType.ts, 9, 34)) +} + +export class B { +>B : Symbol(B, Decl(decoratorMetadataWithConstructorType.ts, 10, 1)) + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) + + x: A = new A(); +>x : Symbol(x, Decl(decoratorMetadataWithConstructorType.ts, 12, 16)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +} + diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.types b/tests/baselines/reference/decoratorMetadataWithConstructorType.types new file mode 100644 index 00000000000..ad83706f4f9 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : { log(msg: string): void; } + + log(msg: string): void; +>log : (msg: string) => void +>msg : string + +}; + +class A { +>A : A + + constructor() { console.log('new A'); } +>console.log('new A') : void +>console.log : (msg: string) => void +>console : { log(msg: string): void; } +>log : (msg: string) => void +>'new A' : string +} + +function decorator(target: Object, propertyKey: string) { +>decorator : (target: Object, propertyKey: string) => void +>target : Object +>Object : Object +>propertyKey : string +} + +export class B { +>B : B + + @decorator +>decorator : (target: Object, propertyKey: string) => void + + x: A = new A(); +>x : A +>A : A +>new A() : A +>A : typeof A +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js new file mode 100644 index 00000000000..392506e5368 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols new file mode 100644 index 00000000000..c967239df99 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : Symbol(db, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + constructor(db: db) { +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types new file mode 100644 index 00000000000..60cf7f10cea --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : MyClass +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : MyClass +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js new file mode 100644 index 00000000000..da011acf110 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols new file mode 100644 index 00000000000..d79b05f68f6 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : Symbol(Database, Decl(service.ts, 0, 8)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: Database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + constructor(db: Database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types new file mode 100644 index 00000000000..73005b4673f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : typeof Database +>Database : typeof Database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: Database; +>db : Database +>Database : Database + + constructor(db: Database) { // no collision +>db : Database +>Database : Database + + this.db = db; +>this.db = db : Database +>this.db : Database +>this : MyClass +>db : Database +>db : Database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : Database +>this : MyClass +>db : Database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js new file mode 100644 index 00000000000..b219bba4102 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols new file mode 100644 index 00000000000..b34468c7bd5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : Symbol(db, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + constructor(db: db.db) { // collision with namespace of external module db +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types new file mode 100644 index 00000000000..0eea3e13b66 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db.db; +>db : db.db +>db : any +>db : db.db + + constructor(db: db.db) { // collision with namespace of external module db +>db : db.db +>db : any +>db : db.db + + this.db = db; +>this.db = db : db.db +>this.db : db.db +>this : MyClass +>db : db.db +>db : db.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db.db +>this : MyClass +>db : db.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt new file mode 100644 index 00000000000..611a0804812 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (1 errors) ==== + import db from './db'; // error no default export + ~~ +!!! error TS1192: Module '"tests/cases/compiler/db"' has no default export. + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js new file mode 100644 index 00000000000..d0d201e62b5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); // error no default export +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js new file mode 100644 index 00000000000..a2599515338 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols new file mode 100644 index 00000000000..6047d7f2882 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : Symbol(db, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + constructor(db: db) { // collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types new file mode 100644 index 00000000000..0fbc48db157 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { // collision +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : MyClass +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : MyClass +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js new file mode 100644 index 00000000000..917cdc7036f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols new file mode 100644 index 00000000000..27f807503bf --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : Symbol(database, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + constructor(db: database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types new file mode 100644 index 00000000000..e3a68882dfb --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database; +>db : database +>database : database + + constructor(db: database) { // no collision +>db : database +>database : database + + this.db = db; +>this.db = db : database +>this.db : database +>this : MyClass +>db : database +>db : database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database +>this : MyClass +>db : database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt new file mode 100644 index 00000000000..d4b714f1d4a --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/service.ts(7,9): error TS2503: Cannot find namespace 'db'. +tests/cases/compiler/service.ts(9,21): error TS2503: Cannot find namespace 'db'. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export default class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (2 errors) ==== + import db from './db'; + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; //error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + + constructor(db: db.db) { // error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js new file mode 100644 index 00000000000..1dd93b12915 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js new file mode 100644 index 00000000000..0aee9e471dd --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var database = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [database.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols new file mode 100644 index 00000000000..1b73ea2e9a3 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : Symbol(database, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + constructor(db: database.db) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types new file mode 100644 index 00000000000..faaab056885 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database.db; +>db : database.db +>database : any +>db : database.db + + constructor(db: database.db) { // no collision +>db : database.db +>database : any +>db : database.db + + this.db = db; +>this.db = db : database.db +>this.db : database.db +>this : MyClass +>db : database.db +>db : database.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database.db +>this : MyClass +>db : database.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt new file mode 100644 index 00000000000..be08d976eeb --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'. +tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does not exist on type '() => number'. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default function Decl() { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + return 0; + } + + export interface Decl { + p1: number; + p2: number; + } + + export namespace Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + export var x = 10; + export var y = 20; + + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + + var x: Entity; + ~~~~~~ +!!! error TS2304: Cannot find name 'Entity'. + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + + Entity.x; + ~ +!!! error TS2339: Property 'x' does not exist on type '() => number'. + Entity.y; + ~ +!!! error TS2339: Property 'y' does not exist on type '() => number'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js new file mode 100644 index 00000000000..99b8ecab1d3 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -0,0 +1,50 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts] //// + +//// [m1.ts] + +export default function Decl() { + return 0; +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + export var x = 10; + export var y = 20; + + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; + +Entity.x; +Entity.y; + +//// [m1.js] +function Decl() { + return 0; +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +var Decl; +(function (Decl) { + Decl.x = 10; + Decl.y = 20; +})(Decl = exports.Decl || (exports.Decl = {})); +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +m1_1.default.x; +m1_1.default.y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt new file mode 100644 index 00000000000..ad9b85c7e94 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default class Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + } + + export interface Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + p1: number; + p2: number; + } + + export namespace Decl { + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? + + var x: Entity; + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + var z = new Entity(); + var sum = z.p1 + z.p2 + ~~ +!!! error TS2339: Property 'p1' does not exist on type 'Decl'. + ~~ +!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js new file mode 100644 index 00000000000..e3897395c74 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts] //// + +//// [m1.ts] + +export default class Decl { +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 + +//// [m1.js] +var Decl = (function () { + function Decl() { + } + return Decl; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +var z = new m1_1.default(); +var sum = z.p1 + z.p2; diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt new file mode 100644 index 00000000000..b1d405671e3 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. + + +==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== + + export default class Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + } + + interface Decl { + ~~~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + p1: number; + p2: number; + } + + namespace Decl { + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? + + var x: Entity; + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + var z = new Entity(); + var sum = z.p1 + z.p2 + ~~ +!!! error TS2339: Property 'p1' does not exist on type 'Decl'. + ~~ +!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js new file mode 100644 index 00000000000..05e7de94120 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts] //// + +//// [m1.ts] + +export default class Decl { +} + +interface Decl { + p1: number; + p2: number; +} + +namespace Decl { + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 + +//// [m1.js] +var Decl = (function () { + function Decl() { + } + return Decl; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +var z = new m1_1.default(); +var sum = z.p1 + z.p2; diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt new file mode 100644 index 00000000000..000a9b8f30e --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(2,25): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(5,11): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(9,11): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(12,18): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + + +==== tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts (4 errors) ==== + + export default function Foo() { + ~~~ +!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. + } + + namespace Foo { + ~~~ +!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. + export var x; + } + + interface Foo { + ~~~ +!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + } + + export interface Foo { + ~~~ +!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + } \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.js b/tests/baselines/reference/defaultExportsCannotMerge04.js new file mode 100644 index 00000000000..eb1122a8197 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge04.js @@ -0,0 +1,23 @@ +//// [defaultExportsCannotMerge04.ts] + +export default function Foo() { +} + +namespace Foo { + export var x; +} + +interface Foo { +} + +export interface Foo { +} + +//// [defaultExportsCannotMerge04.js] +function Foo() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Foo; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index c232eb24636..24774958941 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 89f62f97185..e8cfc29f3a0 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt b/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt index df4f8f13c31..85dd29b78a3 100644 --- a/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt +++ b/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration I must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration I must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration E must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration E must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration inst must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration inst must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration v must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration v must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration w must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration w must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration F must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged -tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration F must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration D must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration D must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. ==== tests/cases/compiler/duplicateSymbolsExportMatching.ts (18 errors) ==== @@ -44,28 +44,28 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind module N2 { interface I { } ~ -!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. export interface I { } // error ~ -!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. export interface E { } ~ -!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. interface E { } // error ~ -!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. } // Should report error only once for instantiated module module M { module inst { ~~~~ -!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. var t; } export module inst { // one error ~~~~ -!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. var t; } } @@ -74,41 +74,41 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind module M2 { var v: string; ~ -!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. export var v: string; // one error (visibility) ~ -!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. var w: number; ~ -!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. export var w: string; // two errors (visibility and type mismatch) ~ -!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. } module M { module F { ~ -!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. ~ !!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged var t; } export function F() { } // Only one error for duplicate identifier (don't consider visibility) ~ -!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. } module M { class C { } ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. module C { } ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. var t; } } @@ -116,7 +116,7 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind // Top level interface D { } ~ -!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. export interface D { } ~ -!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local. \ No newline at end of file +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. \ No newline at end of file diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index ad1482e7f1a..e5275396346 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 42db5aeaa85..230e7158d32 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index 453e04d7521..e304c33e48e 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index b686dd19592..4a309471e64 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 707b99c82c1..e9760caa319 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -10,7 +10,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4392, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/emitBOM.js.map b/tests/baselines/reference/emitBOM.js.map index af5fd260813..69ccb884295 100644 --- a/tests/baselines/reference/emitBOM.js.map +++ b/tests/baselines/reference/emitBOM.js.map @@ -1,2 +1,2 @@ //// [emitBOM.js.map] -{"version":3,"file":"emitBOM.js","sourceRoot":"","sources":["emitBOM.ts"],"names":[],"mappings":"AAEA,AADA,6DAA6D;IACzD,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"emitBOM.js","sourceRoot":"","sources":["emitBOM.ts"],"names":[],"mappings":"AACA,6DAA6D;AAC7D,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/emitBOM.sourcemap.txt b/tests/baselines/reference/emitBOM.sourcemap.txt index cd49155d24f..4cf35c4d1e3 100644 --- a/tests/baselines/reference/emitBOM.sourcemap.txt +++ b/tests/baselines/reference/emitBOM.sourcemap.txt @@ -10,28 +10,27 @@ sourceFile:emitBOM.ts ------------------------------------------------------------------- >>>// JS and d.ts output should have a BOM but not the sourcemap 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > - >// JS and d.ts output should have a BOM but not the sourcemap > -2 > -3 >// JS and d.ts output should have a BOM but not the sourcemap -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -3 >Emitted(1, 62) Source(2, 62) + SourceIndex(0) +2 >// JS and d.ts output should have a BOM but not the sourcemap +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 62) Source(2, 62) + SourceIndex(0) --- >>>var x; -1 >^^^^ -2 > ^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - >var -2 > x -3 > ; -1 >Emitted(2, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(2, 6) Source(3, 6) + SourceIndex(0) -3 >Emitted(2, 7) Source(3, 7) + SourceIndex(0) + > +2 >var +3 > x +4 > ; +1 >Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(2, 6) Source(3, 6) + SourceIndex(0) +4 >Emitted(2, 7) Source(3, 7) + SourceIndex(0) --- >>>//# sourceMappingURL=emitBOM.js.map \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index 57a574d8a06..6e35248cd35 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -139,14 +139,14 @@ var __extends = (this && this.__extends) || function (d, b) { //super property access in instance member accessor(get and set) of class with no base type var NoBase = (function () { function NoBase() { - this.m = _super.prototype; - this.n = _super.hasOwnProperty.call(this, ''); - var a = _super.prototype; - var b = _super.hasOwnProperty.call(this, ''); + this.m = _super.prototype.prototype; + this.n = _super.prototype.hasOwnProperty.call(this, ''); + var a = _super.prototype.prototype; + var b = _super.prototype.hasOwnProperty.call(this, ''); } NoBase.prototype.fn = function () { - var a = _super.prototype; - var b = _super.hasOwnProperty.call(this, ''); + var a = _super.prototype.prototype; + var b = _super.prototype.hasOwnProperty.call(this, ''); }; //super static property access in static member function of class with no base type //super static property access in static member accessor(get and set) of class with no base type diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration2.js b/tests/baselines/reference/es6ImportEqualsDeclaration2.js new file mode 100644 index 00000000000..c7a009a17cf --- /dev/null +++ b/tests/baselines/reference/es6ImportEqualsDeclaration2.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/es6ImportEqualsDeclaration2.ts] //// + +//// [server.d.ts] + +declare module "other" { + export class C { } +} + +declare module "server" { + import events = require("other"); // Ambient declaration, no error expected. + + module S { + export var a: number; + } + + export = S; // Ambient declaration, no error expected. +} + +//// [client.ts] +import {a} from "server"; + + +//// [client.js] diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration2.symbols b/tests/baselines/reference/es6ImportEqualsDeclaration2.symbols new file mode 100644 index 00000000000..a7c556f5be0 --- /dev/null +++ b/tests/baselines/reference/es6ImportEqualsDeclaration2.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/server.d.ts === + +declare module "other" { + export class C { } +>C : Symbol(C, Decl(server.d.ts, 1, 24)) +} + +declare module "server" { + import events = require("other"); // Ambient declaration, no error expected. +>events : Symbol(events, Decl(server.d.ts, 5, 25)) + + module S { +>S : Symbol(S, Decl(server.d.ts, 6, 37)) + + export var a: number; +>a : Symbol(a, Decl(server.d.ts, 9, 18)) + } + + export = S; // Ambient declaration, no error expected. +>S : Symbol(S, Decl(server.d.ts, 6, 37)) +} + +=== tests/cases/compiler/client.ts === +import {a} from "server"; +>a : Symbol(a, Decl(client.ts, 0, 8)) + diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration2.types b/tests/baselines/reference/es6ImportEqualsDeclaration2.types new file mode 100644 index 00000000000..a483d10f25c --- /dev/null +++ b/tests/baselines/reference/es6ImportEqualsDeclaration2.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/server.d.ts === + +declare module "other" { + export class C { } +>C : C +} + +declare module "server" { + import events = require("other"); // Ambient declaration, no error expected. +>events : typeof events + + module S { +>S : typeof S + + export var a: number; +>a : number + } + + export = S; // Ambient declaration, no error expected. +>S : typeof S +} + +=== tests/cases/compiler/client.ts === +import {a} from "server"; +>a : number + diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.js b/tests/baselines/reference/excessPropertyErrorsSuppressed.js new file mode 100644 index 00000000000..1673674c5f3 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.js @@ -0,0 +1,7 @@ +//// [excessPropertyErrorsSuppressed.ts] + +var x: { a: string } = { a: "hello", b: 42 }; // No error + + +//// [excessPropertyErrorsSuppressed.js] +var x = { a: "hello", b: 42 }; // No error diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols new file mode 100644 index 00000000000..01c2846d3e1 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : Symbol(x, Decl(excessPropertyErrorsSuppressed.ts, 1, 3)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 8)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 24)) +>b : Symbol(b, Decl(excessPropertyErrorsSuppressed.ts, 1, 36)) + diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.types b/tests/baselines/reference/excessPropertyErrorsSuppressed.types new file mode 100644 index 00000000000..47a4dbf92a9 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : { a: string; } +>a : string +>{ a: "hello", b: 42 } : { a: string; b: number; } +>a : string +>"hello" : string +>b : number +>42 : number + diff --git a/tests/baselines/reference/extendClassExpressionFromModule.js b/tests/baselines/reference/extendClassExpressionFromModule.js new file mode 100644 index 00000000000..cbd36f7e799 --- /dev/null +++ b/tests/baselines/reference/extendClassExpressionFromModule.js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/classes/classExpressions/extendClassExpressionFromModule.ts] //// + +//// [foo1.ts] +class x{} + +export = x; + +//// [foo2.ts] +import foo1 = require('./foo1'); +var x = foo1; +class y extends x {} + + +//// [foo1.js] +var x = (function () { + function x() { + } + return x; +})(); +module.exports = x; +//// [foo2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo1 = require('./foo1'); +var x = foo1; +var y = (function (_super) { + __extends(y, _super); + function y() { + _super.apply(this, arguments); + } + return y; +})(x); diff --git a/tests/baselines/reference/extendClassExpressionFromModule.symbols b/tests/baselines/reference/extendClassExpressionFromModule.symbols new file mode 100644 index 00000000000..c131ea8fa28 --- /dev/null +++ b/tests/baselines/reference/extendClassExpressionFromModule.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/classes/classExpressions/foo2.ts === +import foo1 = require('./foo1'); +>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0)) + +var x = foo1; +>x : Symbol(x, Decl(foo2.ts, 1, 3)) +>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0)) + +class y extends x {} +>y : Symbol(y, Decl(foo2.ts, 1, 13)) + +=== tests/cases/conformance/classes/classExpressions/foo1.ts === +class x{} +>x : Symbol(x, Decl(foo1.ts, 0, 0)) + +export = x; +>x : Symbol(x, Decl(foo1.ts, 0, 0)) + diff --git a/tests/baselines/reference/extendClassExpressionFromModule.types b/tests/baselines/reference/extendClassExpressionFromModule.types new file mode 100644 index 00000000000..d03623d50aa --- /dev/null +++ b/tests/baselines/reference/extendClassExpressionFromModule.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classExpressions/foo2.ts === +import foo1 = require('./foo1'); +>foo1 : typeof foo1 + +var x = foo1; +>x : typeof foo1 +>foo1 : typeof foo1 + +class y extends x {} +>y : y +>x : foo1 + +=== tests/cases/conformance/classes/classExpressions/foo1.ts === +class x{} +>x : x + +export = x; +>x : x + diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.errors.txt b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.errors.txt index 5934ab52ccf..b32a7b67b61 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.errors.txt +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.errors.txt @@ -1,10 +1,9 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(1,9): error TS1016: A required parameter cannot follow an optional parameter. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(2,8): error TS1047: A rest parameter cannot be optional. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(4,5): error TS1048: A rest parameter cannot have an initializer. -tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016: A required parameter cannot follow an optional parameter. -==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (4 errors) ==== +==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (3 errors) ==== (arg1?, arg2) => 101; ~~~~ !!! error TS1016: A required parameter cannot follow an optional parameter. @@ -16,7 +15,5 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016 ~~~ !!! error TS1048: A rest parameter cannot have an initializer. - // Non optional parameter following an optional one - (arg1 = 1, arg2) => 1; - ~~~~ -!!! error TS1016: A required parameter cannot follow an optional parameter. \ No newline at end of file + // Uninitialized parameter makes the initialized one required + (arg1 = 1, arg2) => 1; \ No newline at end of file diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js index e746b24a066..4d27f8230eb 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js @@ -4,7 +4,7 @@ (...arg) => 103; (...arg:number [] = []) => 104; -// Non optional parameter following an optional one +// Uninitialized parameter makes the initialized one required (arg1 = 1, arg2) => 1; //// [fatarrowfunctionsOptionalArgsErrors1.js] @@ -30,7 +30,7 @@ } return 104; }); -// Non optional parameter following an optional one +// Uninitialized parameter makes the initialized one required (function (arg1, arg2) { if (arg1 === void 0) { arg1 = 1; } return 1; diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 08e5f4ff468..e465f36a50f 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 4119, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 4119, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 066d9534051..76621026a00 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 8c34f6f0d7a..35892922df3 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 4e7aaf7e362..f01969e23bb 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 70c1132afbd..c740cf62446 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 46507255937..bf4304a8216 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 8401de024d9..a45775127b0 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 93e918c4bcd..ef08deb568d 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 04445f50171..abaa0a92dcc 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 4c645d359dd..727574805b9 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 6887b46a44d..4e1bf8ad3dc 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index a726b7eedc2..e6a10d77cad 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 11ff91e1162..43df250ab95 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index f6619ff753d..e1e413424ad 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index a9ea283d673..839de020702 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 1d447ea87cc..87c227f5dc9 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index 6b8012c7929..c01a37bf409 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index b8d01d3bd1b..ff061ffcca1 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 098afe94b47..53ecb88363d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/forwardRefInEnum.errors.txt b/tests/baselines/reference/forwardRefInEnum.errors.txt new file mode 100644 index 00000000000..0f2c359402f --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + + +==== tests/cases/compiler/forwardRefInEnum.ts (4 errors) ==== + enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + ~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + X1 = E1["Y"], + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + // forward reference to the element of the same enum + Y = E1.Z, + ~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + Y1 = E1["Z"] + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + } + + enum E1 { + Z = 4 + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInEnum.js b/tests/baselines/reference/forwardRefInEnum.js new file mode 100644 index 00000000000..76e2575ec8d --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.js @@ -0,0 +1,31 @@ +//// [forwardRefInEnum.ts] +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} + + +//// [forwardRefInEnum.js] +var E1; +(function (E1) { + // illegal case + // forward reference to the element of the same enum + E1[E1["X"] = E1.Y] = "X"; + E1[E1["X1"] = E1["Y"]] = "X1"; + // forward reference to the element of the same enum + E1[E1["Y"] = E1.Z] = "Y"; + E1[E1["Y1"] = E1["Z"]] = "Y1"; +})(E1 || (E1 = {})); +var E1; +(function (E1) { + E1[E1["Z"] = 4] = "Z"; +})(E1 || (E1 = {})); diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index 03ce9952938..871368da9fe 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -14,7 +14,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(34,16): error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(36,38): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'. - Type 'void' is not assignable to type 'string'. + Type '() => void' is not assignable to type '(x: string) => string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. @@ -85,7 +85,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain foo2(x); ~ !!! error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'. -!!! error TS2345: Type 'void' is not assignable to type 'string'. +!!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'. foo2(y); ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 4facd65bda7..1398e2974f0 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -342,7 +342,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb var f8: (x: number) => any = x => { // should be (x: number) => Base >f8 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base >x : number return new Base(); @@ -356,7 +356,7 @@ var f8: (x: number) => any = x => { // should be (x: number) => Base var f9: (x: number) => any = x => { // should be (x: number) => Base >f9 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base | Derived | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base >x : number return new Base(); diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 06745d0d7aa..e8f434d31a8 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2125,8 +2125,8 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >d2 : Derived2 var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x217 : () => Base[] +>(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2137,8 +2137,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x218 : () => Base[] +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2150,8 +2150,8 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x219 : () => Base[] +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2162,8 +2162,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x220 : () => Base[] +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2175,8 +2175,8 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x221 = (undefined) || [d1, d2]; ->x221 : Base[] | (Derived1 | Derived2)[] ->(undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x221 : Base[] +>(undefined) || [d1, d2] : Base[] >(undefined) : Base[] >undefined : Base[] >Base : Base @@ -2186,8 +2186,8 @@ var x221 = (undefined) || [d1, d2]; >d2 : Derived2 var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] | (Derived1 | Derived2)[] ->(>undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x222 : Base[] +>(>undefined) || [d1, d2] : Base[] >(>undefined) : Base[] >>undefined : Base[] >Array : T[] @@ -2198,8 +2198,8 @@ var x222 = (>undefined) || [d1, d2]; >d2 : Derived2 var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } | (Derived1 | Derived2)[] ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } | (Derived1 | Derived2)[] +>x223 : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } >(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } ><{ [n: number]: Base; }>undefined : { [n: number]: Base; } >n : number @@ -2210,8 +2210,8 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >d2 : Derived2 var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } +>x224 : { n: Base[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } >(<{n: Base[]; } >undefined) : { n: Base[]; } ><{n: Base[]; } >undefined : { n: Base[]; } >n : Base[] diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 7f30b4f6797..f424048eeec 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index c4fb9401517..647576d081e 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 509ed22d197..e876a2619d2 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index 79cc3e275ad..728084f01d0 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index 6247bd7b85c..f00d72007f5 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index dce2524d1ba..48a1abfbaca 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index f9c9b7b6e22..745e4831b12 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index bc43ea8c8f9..c6189a6ef64 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index 789eb22347c..51d6c40ae37 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index e7a5898099f..12bf5e5e34e 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index 5a0aec4d592..c03276b6c9b 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index 08cc7289ef8..399e4ccc497 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index fcee922d1e9..3d0a66382c6 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index 27b246515f6..96ce1e27c63 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index 260137dd1cf..b01b97eb763 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index a149a592e3d..79a3164e2d2 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4373, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index 086c65685a8..e337277aa43 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index 89c01ff0203..9cf40641ad6 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4363, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index 72d8ebf57a1..8b3bf966681 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index f9f230b5776..c264058ad9f 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -5,7 +5,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'T' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'RegExp'. + Type 'RegExp' is not assignable to type 'Date'. + Property 'toDateString' is missing in type 'RegExp'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,36): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. Type 'F' is not assignable to type 'E'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. @@ -13,6 +14,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'T' is not assignable to type 'Date'. + Type 'RegExp' is not assignable to type 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,51): error TS2304: Cannot find name 'U'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,57): error TS2304: Cannot find name 'U'. @@ -54,7 +56,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen !!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. !!! error TS2345: Types of parameters 'a' and 'x' are incompatible. !!! error TS2345: Type 'T' is not assignable to type 'Date'. -!!! error TS2345: Property 'toDateString' is missing in type 'RegExp'. +!!! error TS2345: Type 'RegExp' is not assignable to type 'Date'. +!!! error TS2345: Property 'toDateString' is missing in type 'RegExp'. var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date } @@ -101,6 +104,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen !!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. !!! error TS2345: Types of parameters 'a' and 'x' are incompatible. !!! error TS2345: Type 'T' is not assignable to type 'Date'. +!!! error TS2345: Type 'RegExp' is not assignable to type 'Date'. var r7b = foo2((a) => a, (b) => b); } diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt index 2a7bfd696cc..b0c0bee94fd 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt @@ -1,9 +1,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(15,17): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(18,9): error TS2413: Numeric index type 'T' is not assignable to string index type 'Object'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts (2 errors) ==== // Type inference infers from indexers in target type, error cases function foo(x: T) { @@ -24,8 +23,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var b: { [x: string]: Object; [x: number]: T; - ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'T' is not assignable to string index type 'Object'. }; var r2 = foo(b); var d = r2[1]; diff --git a/tests/baselines/reference/genericTypeAssertions6.errors.txt b/tests/baselines/reference/genericTypeAssertions6.errors.txt index 93677b9ab84..29ca99ecb1a 100644 --- a/tests/baselines/reference/genericTypeAssertions6.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions6.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Neither type 'U' nor type 'T' is assignable to the other. tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Neither type 'T' nor type 'U' is assignable to the other. tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Neither type 'U' nor type 'T' is assignable to the other. + Type 'Date' is not assignable to type 'T'. ==== tests/cases/compiler/genericTypeAssertions6.ts (3 errors) ==== @@ -29,6 +30,7 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Neither typ var e = new Date(); ~~~~~~~~~~~~~~~~ !!! error TS2352: Neither type 'U' nor type 'T' is assignable to the other. +!!! error TS2352: Type 'Date' is not assignable to type 'T'. } } diff --git a/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt b/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt index ae93d059f9a..0fe15afcf33 100644 --- a/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt +++ b/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt @@ -3,8 +3,9 @@ tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(4,7): error TS2420 Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. Types of parameters 'a' and 'a' are incompatible. Type 'T' is not assignable to type '{ a: number; }'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '{ a: string; }' is not assignable to type '{ a: number; }'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(8,5): error TS2322: Type 'X<{ a: string; }>' is not assignable to type 'I'. Types of property 'f' are incompatible. Type '(a: { a: string; }) => void' is not assignable to type '(a: { a: number; }) => void'. @@ -25,8 +26,9 @@ tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(8,5): error TS2322 !!! error TS2420: Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. !!! error TS2420: Types of parameters 'a' and 'a' are incompatible. !!! error TS2420: Type 'T' is not assignable to type '{ a: number; }'. -!!! error TS2420: Types of property 'a' are incompatible. -!!! error TS2420: Type 'string' is not assignable to type 'number'. +!!! error TS2420: Type '{ a: string; }' is not assignable to type '{ a: number; }'. +!!! error TS2420: Types of property 'a' are incompatible. +!!! error TS2420: Type 'string' is not assignable to type 'number'. f(a: T): void { } } var x = new X<{ a: string }>(); diff --git a/tests/baselines/reference/getEmitOutput-pp.baseline b/tests/baselines/reference/getEmitOutput-pp.baseline new file mode 100644 index 00000000000..d5487a14d95 --- /dev/null +++ b/tests/baselines/reference/getEmitOutput-pp.baseline @@ -0,0 +1,30 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/shims-pp/inputFile1.js +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +FileName : tests/cases/fourslash/shims-pp/inputFile1.d.ts +declare var x: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/shims-pp/inputFile2.js +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +FileName : tests/cases/fourslash/shims-pp/inputFile2.d.ts +declare var x1: string; +declare class Foo { + x: string; + y: number; +} + diff --git a/tests/baselines/reference/getEmitOutputOutFile.baseline b/tests/baselines/reference/getEmitOutputOutFile.baseline new file mode 100644 index 00000000000..702097a7c03 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputOutFile.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : outFile.js +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +FileName : outFile.d.ts +declare var x: number; +declare class Bar { + x: string; + y: number; +} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline new file mode 100644 index 00000000000..2ae820dd538 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.jsx.map +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.jsx +var y = "my div"; +var x =
; +//# sourceMappingURL=inputFile2.jsx.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline new file mode 100644 index 00000000000..c796f8e78bc --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,KAAC,IAAI,GAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js +var y = "my div"; +var x = React.createElement("div", {"name": y}); +//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 952200d74f8..c760e5a566f 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -21,14 +21,14 @@ var c = [1, '', null]; // {}[] >null : null var d = [{}, 1]; // {}[] ->d : ({} | number)[] ->[{}, 1] : ({} | number)[] +>d : {}[] +>[{}, 1] : {}[] >{} : {} >1 : number var e = [{}, Object]; // {}[] ->e : ({} | ObjectConstructor)[] ->[{}, Object] : ({} | ObjectConstructor)[] +>e : {}[] +>[{}, Object] : {}[] >{} : {} >Object : ObjectConstructor @@ -88,16 +88,16 @@ var k = [() => 1, () => 1]; // { (): number }[] >1 : number var l = [() => 1, () => null]; // { (): any }[] ->l : ((() => number) | (() => any))[] ->[() => 1, () => null] : ((() => number) | (() => any))[] +>l : (() => any)[] +>[() => 1, () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => null : () => any >null : null var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : ((() => number) | (() => string) | (() => any))[] ->[() => 1, () => '', () => null] : ((() => number) | (() => string) | (() => any))[] +>m : (() => any)[] +>[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => '' : () => string @@ -169,8 +169,8 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : ((() => Base) | (() => Derived))[] ->[() => base, () => derived] : ((() => Base) | (() => Derived))[] +>j : (() => Base)[] +>[() => base, () => derived] : (() => Base)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -185,16 +185,16 @@ module Derived { >1 : number var l = [() => base, () => null]; // { (): any }[] ->l : ((() => Base) | (() => any))[] ->[() => base, () => null] : ((() => Base) | (() => any))[] +>l : (() => any)[] +>[() => base, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => null : () => any >null : null var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : ((() => Base) | (() => Derived) | (() => any))[] ->[() => base, () => derived, () => null] : ((() => Base) | (() => Derived) | (() => any))[] +>m : (() => any)[] +>[() => base, () => derived, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -203,8 +203,8 @@ module Derived { >null : null var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : ((() => Base)[] | (() => Derived)[])[] ->[[() => base], [() => derived]] : ((() => Base)[] | (() => Derived)[])[] +>n : (() => Base)[][] +>[[() => base], [() => derived]] : (() => Base)[][] >[() => base] : (() => Base)[] >() => base : () => Base >base : Base @@ -219,8 +219,8 @@ module Derived { >derived2 : Derived2 var p = [derived, derived2, base]; // Base[] ->p : (Derived | Derived2 | Base)[] ->[derived, derived2, base] : (Derived | Derived2 | Base)[] +>p : Base[] +>[derived, derived2, base] : Base[] >derived : Derived >derived2 : Derived2 >base : Base @@ -310,8 +310,8 @@ function foo(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -364,8 +364,8 @@ function foo2(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -374,8 +374,8 @@ function foo2(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -386,14 +386,14 @@ function foo2(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -442,8 +442,8 @@ function foo3(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -452,26 +452,26 @@ function foo3(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (T | Derived)[] ->[t, derived] : (T | Derived)[] +>h : Derived[] +>[t, derived] : Derived[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -520,8 +520,8 @@ function foo4(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -530,8 +530,8 @@ function foo4(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -542,8 +542,8 @@ function foo4(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 9f4b403ca2e..9e003197e41 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -1,14 +1,13 @@ tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. -tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. -==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ==== +==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ==== interface Red { [n:number]; // ok ~~~~~~~~~~~ @@ -37,8 +36,6 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression interface Green { [n:number]: Orange; // error - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. [s:string]: Yellow; // ok } diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.types b/tests/baselines/reference/inferentialTypingUsingApparentType2.types index 597f5885f5a..5841e021c3a 100644 --- a/tests/baselines/reference/inferentialTypingUsingApparentType2.types +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.types @@ -13,7 +13,7 @@ function foo(x: T): T { } foo({ m(x) { return x.length } }); ->foo({ m(x) { return x.length } }) : { } +>foo({ m(x) { return x.length } }) : { m(x: string): number; } >foo : (x: T) => T >{ m(x) { return x.length } } : { m(x: string): number; } >m : (x: string) => number diff --git a/tests/baselines/reference/inferringAnyFunctionType1.js b/tests/baselines/reference/inferringAnyFunctionType1.js new file mode 100644 index 00000000000..6b48cf2db58 --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType1.js @@ -0,0 +1,12 @@ +//// [inferringAnyFunctionType1.ts] +function f number }>(p: T): T { + return p; +} + +var v = f([x => x]); + +//// [inferringAnyFunctionType1.js] +function f(p) { + return p; +} +var v = f([function (x) { return x; }]); diff --git a/tests/baselines/reference/inferringAnyFunctionType1.symbols b/tests/baselines/reference/inferringAnyFunctionType1.symbols new file mode 100644 index 00000000000..6a43952d770 --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType1.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/inferringAnyFunctionType1.ts === +function f number }>(p: T): T { +>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0)) +>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11)) +>p1 : Symbol(p1, Decl(inferringAnyFunctionType1.ts, 0, 29)) +>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54)) +>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11)) +>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11)) + + return p; +>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54)) +} + +var v = f([x => x]); +>v : Symbol(v, Decl(inferringAnyFunctionType1.ts, 4, 3)) +>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0)) +>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11)) +>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11)) + diff --git a/tests/baselines/reference/inferringAnyFunctionType1.types b/tests/baselines/reference/inferringAnyFunctionType1.types new file mode 100644 index 00000000000..16402cc3ced --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType1.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferringAnyFunctionType1.ts === +function f number }>(p: T): T { +>f : number; }>(p: T) => T +>T : T +>p1 : number +>p : T +>T : T +>T : T + + return p; +>p : T +} + +var v = f([x => x]); +>v : [(x: number) => number] +>f([x => x]) : [(x: number) => number] +>f : number; }>(p: T) => T +>[x => x] : [(x: number) => number] +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/baselines/reference/inferringAnyFunctionType2.js b/tests/baselines/reference/inferringAnyFunctionType2.js new file mode 100644 index 00000000000..3841793233e --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType2.js @@ -0,0 +1,12 @@ +//// [inferringAnyFunctionType2.ts] +function f number]>(p: T): T { + return p; +} + +var v = f([x => x]); + +//// [inferringAnyFunctionType2.js] +function f(p) { + return p; +} +var v = f([function (x) { return x; }]); diff --git a/tests/baselines/reference/inferringAnyFunctionType2.symbols b/tests/baselines/reference/inferringAnyFunctionType2.symbols new file mode 100644 index 00000000000..9bdb627d46d --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/inferringAnyFunctionType2.ts === +function f number]>(p: T): T { +>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0)) +>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11)) +>p1 : Symbol(p1, Decl(inferringAnyFunctionType2.ts, 0, 23)) +>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47)) +>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11)) +>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11)) + + return p; +>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47)) +} + +var v = f([x => x]); +>v : Symbol(v, Decl(inferringAnyFunctionType2.ts, 4, 3)) +>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0)) +>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11)) +>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11)) + diff --git a/tests/baselines/reference/inferringAnyFunctionType2.types b/tests/baselines/reference/inferringAnyFunctionType2.types new file mode 100644 index 00000000000..7884bdfc6ba --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType2.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferringAnyFunctionType2.ts === +function f number]>(p: T): T { +>f : number]>(p: T) => T +>T : T +>p1 : number +>p : T +>T : T +>T : T + + return p; +>p : T +} + +var v = f([x => x]); +>v : [(x: number) => number] +>f([x => x]) : [(x: number) => number] +>f : number]>(p: T) => T +>[x => x] : [(x: number) => number] +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/baselines/reference/inferringAnyFunctionType3.js b/tests/baselines/reference/inferringAnyFunctionType3.js new file mode 100644 index 00000000000..ed1c4348dfc --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType3.js @@ -0,0 +1,12 @@ +//// [inferringAnyFunctionType3.ts] +function f number)[]>(p: T): T { + return p; +} + +var v = f([x => x]); + +//// [inferringAnyFunctionType3.js] +function f(p) { + return p; +} +var v = f([function (x) { return x; }]); diff --git a/tests/baselines/reference/inferringAnyFunctionType3.symbols b/tests/baselines/reference/inferringAnyFunctionType3.symbols new file mode 100644 index 00000000000..472d170b81d --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType3.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/inferringAnyFunctionType3.ts === +function f number)[]>(p: T): T { +>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0)) +>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11)) +>p1 : Symbol(p1, Decl(inferringAnyFunctionType3.ts, 0, 23)) +>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49)) +>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11)) +>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11)) + + return p; +>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49)) +} + +var v = f([x => x]); +>v : Symbol(v, Decl(inferringAnyFunctionType3.ts, 4, 3)) +>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0)) +>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11)) +>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11)) + diff --git a/tests/baselines/reference/inferringAnyFunctionType3.types b/tests/baselines/reference/inferringAnyFunctionType3.types new file mode 100644 index 00000000000..1edcfc34643 --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType3.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferringAnyFunctionType3.ts === +function f number)[]>(p: T): T { +>f : number)[]>(p: T) => T +>T : T +>p1 : number +>p : T +>T : T +>T : T + + return p; +>p : T +} + +var v = f([x => x]); +>v : ((x: number) => number)[] +>f([x => x]) : ((x: number) => number)[] +>f : number)[]>(p: T) => T +>[x => x] : ((x: number) => number)[] +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/baselines/reference/inferringAnyFunctionType4.js b/tests/baselines/reference/inferringAnyFunctionType4.js new file mode 100644 index 00000000000..dccc51920b0 --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType4.js @@ -0,0 +1,12 @@ +//// [inferringAnyFunctionType4.ts] +function f number>(p: T): T { + return p; +} + +var v = f(x => x); + +//// [inferringAnyFunctionType4.js] +function f(p) { + return p; +} +var v = f(function (x) { return x; }); diff --git a/tests/baselines/reference/inferringAnyFunctionType4.symbols b/tests/baselines/reference/inferringAnyFunctionType4.symbols new file mode 100644 index 00000000000..bfbacfc277c --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType4.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/inferringAnyFunctionType4.ts === +function f number>(p: T): T { +>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0)) +>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11)) +>p1 : Symbol(p1, Decl(inferringAnyFunctionType4.ts, 0, 22)) +>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45)) +>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11)) +>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11)) + + return p; +>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45)) +} + +var v = f(x => x); +>v : Symbol(v, Decl(inferringAnyFunctionType4.ts, 4, 3)) +>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0)) +>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10)) +>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10)) + diff --git a/tests/baselines/reference/inferringAnyFunctionType4.types b/tests/baselines/reference/inferringAnyFunctionType4.types new file mode 100644 index 00000000000..49d46d0433e --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType4.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/inferringAnyFunctionType4.ts === +function f number>(p: T): T { +>f : number>(p: T) => T +>T : T +>p1 : number +>p : T +>T : T +>T : T + + return p; +>p : T +} + +var v = f(x => x); +>v : (x: number) => number +>f(x => x) : (x: number) => number +>f : number>(p: T) => T +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/baselines/reference/inferringAnyFunctionType5.js b/tests/baselines/reference/inferringAnyFunctionType5.js new file mode 100644 index 00000000000..babbab1be9e --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType5.js @@ -0,0 +1,12 @@ +//// [inferringAnyFunctionType5.ts] +function f number }>(p: T): T { + return p; +} + +var v = f({ q: x => x }); + +//// [inferringAnyFunctionType5.js] +function f(p) { + return p; +} +var v = f({ q: function (x) { return x; } }); diff --git a/tests/baselines/reference/inferringAnyFunctionType5.symbols b/tests/baselines/reference/inferringAnyFunctionType5.symbols new file mode 100644 index 00000000000..abf0fe68f46 --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType5.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/inferringAnyFunctionType5.ts === +function f number }>(p: T): T { +>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0)) +>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11)) +>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 0, 22)) +>p1 : Symbol(p1, Decl(inferringAnyFunctionType5.ts, 0, 27)) +>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52)) +>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11)) +>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11)) + + return p; +>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52)) +} + +var v = f({ q: x => x }); +>v : Symbol(v, Decl(inferringAnyFunctionType5.ts, 4, 3)) +>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0)) +>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 4, 11)) +>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14)) +>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14)) + diff --git a/tests/baselines/reference/inferringAnyFunctionType5.types b/tests/baselines/reference/inferringAnyFunctionType5.types new file mode 100644 index 00000000000..8f7ae123eac --- /dev/null +++ b/tests/baselines/reference/inferringAnyFunctionType5.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/inferringAnyFunctionType5.ts === +function f number }>(p: T): T { +>f : number; }>(p: T) => T +>T : T +>q : (p1: number) => number +>p1 : number +>p : T +>T : T +>T : T + + return p; +>p : T +} + +var v = f({ q: x => x }); +>v : { q: (x: number) => number; } +>f({ q: x => x }) : { q: (x: number) => number; } +>f : number; }>(p: T) => T +>{ q: x => x } : { q: (x: number) => number; } +>q : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/baselines/reference/inlineSourceMap2.errors.txt b/tests/baselines/reference/inlineSourceMap2.errors.txt index 2d8bc4be0c1..24b0fddf942 100644 --- a/tests/baselines/reference/inlineSourceMap2.errors.txt +++ b/tests/baselines/reference/inlineSourceMap2.errors.txt @@ -1,12 +1,12 @@ -error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'. -!!! error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -!!! error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -!!! error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. ==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ==== // configuration errors diff --git a/tests/baselines/reference/innerModExport2.errors.txt b/tests/baselines/reference/innerModExport2.errors.txt index 52a9d01c997..f9568bb45a4 100644 --- a/tests/baselines/reference/innerModExport2.errors.txt +++ b/tests/baselines/reference/innerModExport2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/innerModExport2.ts(5,5): error TS2304: Cannot find name 'module'. tests/cases/compiler/innerModExport2.ts(5,12): error TS1005: ';' expected. -tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. -tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. +tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExportFunc' does not exist on type 'typeof Outer'. @@ -18,7 +18,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport var non_export_var = 0; export var export_var = 1; ~~~~~~~~~~ -!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. function NonExportFunc() { return 0; } @@ -26,7 +26,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport } var export_var: number; ~~~~~~~~~~ -!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. export var outer_var_export = 0; export function outerFuncExport() { return 0; } diff --git a/tests/baselines/reference/instanceOfAssignability.js b/tests/baselines/reference/instanceOfAssignability.js new file mode 100644 index 00000000000..4a1e8b9e9de --- /dev/null +++ b/tests/baselines/reference/instanceOfAssignability.js @@ -0,0 +1,187 @@ +//// [instanceOfAssignability.ts] +interface Base { + foo: string|number; + optional?: number; +} + +// Derived1 is assignable to, but not a subtype of, Base +class Derived1 implements Base { + foo: string; +} +// Derived2 is a subtype of Base that is not assignable to Derived1 +class Derived2 implements Base { + foo: number; + optional: number; +} + +class Animal { + move; +} +class Mammal extends Animal { milk; } +class Giraffe extends Mammal { neck; } + +function fn1(x: Array|Array|boolean) { + if(x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; + } +} + +function fn2(x: Base) { + if(x instanceof Derived1) { + // 1.5: y: Base + // Want: y: Derived1 + let y = x; + } +} + +function fn3(x: Base|Derived1) { + if(x instanceof Derived2) { + // 1.5: y: Derived2 + // Want: Derived2 + let y = x; + } +} + +function fn4(x: Base|Derived2) { + if(x instanceof Derived1) { + // 1.5: y: {} + // Want: Derived1 + let y = x; + } +} + +function fn5(x: Derived1) { + if(x instanceof Derived2) { + // 1.5: y: Derived1 + // Want: ??? + let y = x; + } +} + +function fn6(x: Animal|Mammal) { + if(x instanceof Giraffe) { + // 1.5: y: Derived1 + // Want: ??? + let y = x; + } +} + +function fn7(x: Array|Array) { + if(x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; + } +} + +interface Alpha { a } +interface Beta { b } +interface Gamma { c } +class ABC { a; b; c; } +function fn8(x: Alpha|Beta|Gamma) { + if(x instanceof ABC) { + let y = x; + } +} + + + + +//// [instanceOfAssignability.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +// Derived1 is assignable to, but not a subtype of, Base +var Derived1 = (function () { + function Derived1() { + } + return Derived1; +})(); +// Derived2 is a subtype of Base that is not assignable to Derived1 +var Derived2 = (function () { + function Derived2() { + } + return Derived2; +})(); +var Animal = (function () { + function Animal() { + } + return Animal; +})(); +var Mammal = (function (_super) { + __extends(Mammal, _super); + function Mammal() { + _super.apply(this, arguments); + } + return Mammal; +})(Animal); +var Giraffe = (function (_super) { + __extends(Giraffe, _super); + function Giraffe() { + _super.apply(this, arguments); + } + return Giraffe; +})(Mammal); +function fn1(x) { + if (x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + var y = x; + } +} +function fn2(x) { + if (x instanceof Derived1) { + // 1.5: y: Base + // Want: y: Derived1 + var y = x; + } +} +function fn3(x) { + if (x instanceof Derived2) { + // 1.5: y: Derived2 + // Want: Derived2 + var y = x; + } +} +function fn4(x) { + if (x instanceof Derived1) { + // 1.5: y: {} + // Want: Derived1 + var y = x; + } +} +function fn5(x) { + if (x instanceof Derived2) { + // 1.5: y: Derived1 + // Want: ??? + var y = x; + } +} +function fn6(x) { + if (x instanceof Giraffe) { + // 1.5: y: Derived1 + // Want: ??? + var y = x; + } +} +function fn7(x) { + if (x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + var y = x; + } +} +var ABC = (function () { + function ABC() { + } + return ABC; +})(); +function fn8(x) { + if (x instanceof ABC) { + var y = x; + } +} diff --git a/tests/baselines/reference/instanceOfAssignability.symbols b/tests/baselines/reference/instanceOfAssignability.symbols new file mode 100644 index 00000000000..b01f29a5faf --- /dev/null +++ b/tests/baselines/reference/instanceOfAssignability.symbols @@ -0,0 +1,208 @@ +=== tests/cases/compiler/instanceOfAssignability.ts === +interface Base { +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) + + foo: string|number; +>foo : Symbol(foo, Decl(instanceOfAssignability.ts, 0, 16)) + + optional?: number; +>optional : Symbol(optional, Decl(instanceOfAssignability.ts, 1, 20)) +} + +// Derived1 is assignable to, but not a subtype of, Base +class Derived1 implements Base { +>Derived1 : Symbol(Derived1, Decl(instanceOfAssignability.ts, 3, 1)) +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) + + foo: string; +>foo : Symbol(foo, Decl(instanceOfAssignability.ts, 6, 32)) +} +// Derived2 is a subtype of Base that is not assignable to Derived1 +class Derived2 implements Base { +>Derived2 : Symbol(Derived2, Decl(instanceOfAssignability.ts, 8, 1)) +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) + + foo: number; +>foo : Symbol(foo, Decl(instanceOfAssignability.ts, 10, 32)) + + optional: number; +>optional : Symbol(optional, Decl(instanceOfAssignability.ts, 11, 13)) +} + +class Animal { +>Animal : Symbol(Animal, Decl(instanceOfAssignability.ts, 13, 1)) + + move; +>move : Symbol(move, Decl(instanceOfAssignability.ts, 15, 14)) +} +class Mammal extends Animal { milk; } +>Mammal : Symbol(Mammal, Decl(instanceOfAssignability.ts, 17, 1)) +>Animal : Symbol(Animal, Decl(instanceOfAssignability.ts, 13, 1)) +>milk : Symbol(milk, Decl(instanceOfAssignability.ts, 18, 29)) + +class Giraffe extends Mammal { neck; } +>Giraffe : Symbol(Giraffe, Decl(instanceOfAssignability.ts, 18, 37)) +>Mammal : Symbol(Mammal, Decl(instanceOfAssignability.ts, 17, 1)) +>neck : Symbol(neck, Decl(instanceOfAssignability.ts, 19, 30)) + +function fn1(x: Array|Array|boolean) { +>fn1 : Symbol(fn1, Decl(instanceOfAssignability.ts, 19, 38)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 21, 13)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + + if(x instanceof Array) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 21, 13)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 25, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 21, 13)) + } +} + +function fn2(x: Base) { +>fn2 : Symbol(fn2, Decl(instanceOfAssignability.ts, 27, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 29, 13)) +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) + + if(x instanceof Derived1) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 29, 13)) +>Derived1 : Symbol(Derived1, Decl(instanceOfAssignability.ts, 3, 1)) + + // 1.5: y: Base + // Want: y: Derived1 + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 33, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 29, 13)) + } +} + +function fn3(x: Base|Derived1) { +>fn3 : Symbol(fn3, Decl(instanceOfAssignability.ts, 35, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 37, 13)) +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) +>Derived1 : Symbol(Derived1, Decl(instanceOfAssignability.ts, 3, 1)) + + if(x instanceof Derived2) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 37, 13)) +>Derived2 : Symbol(Derived2, Decl(instanceOfAssignability.ts, 8, 1)) + + // 1.5: y: Derived2 + // Want: Derived2 + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 41, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 37, 13)) + } +} + +function fn4(x: Base|Derived2) { +>fn4 : Symbol(fn4, Decl(instanceOfAssignability.ts, 43, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 45, 13)) +>Base : Symbol(Base, Decl(instanceOfAssignability.ts, 0, 0)) +>Derived2 : Symbol(Derived2, Decl(instanceOfAssignability.ts, 8, 1)) + + if(x instanceof Derived1) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 45, 13)) +>Derived1 : Symbol(Derived1, Decl(instanceOfAssignability.ts, 3, 1)) + + // 1.5: y: {} + // Want: Derived1 + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 49, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 45, 13)) + } +} + +function fn5(x: Derived1) { +>fn5 : Symbol(fn5, Decl(instanceOfAssignability.ts, 51, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 53, 13)) +>Derived1 : Symbol(Derived1, Decl(instanceOfAssignability.ts, 3, 1)) + + if(x instanceof Derived2) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 53, 13)) +>Derived2 : Symbol(Derived2, Decl(instanceOfAssignability.ts, 8, 1)) + + // 1.5: y: Derived1 + // Want: ??? + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 57, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 53, 13)) + } +} + +function fn6(x: Animal|Mammal) { +>fn6 : Symbol(fn6, Decl(instanceOfAssignability.ts, 59, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 61, 13)) +>Animal : Symbol(Animal, Decl(instanceOfAssignability.ts, 13, 1)) +>Mammal : Symbol(Mammal, Decl(instanceOfAssignability.ts, 17, 1)) + + if(x instanceof Giraffe) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 61, 13)) +>Giraffe : Symbol(Giraffe, Decl(instanceOfAssignability.ts, 18, 37)) + + // 1.5: y: Derived1 + // Want: ??? + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 65, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 61, 13)) + } +} + +function fn7(x: Array|Array) { +>fn7 : Symbol(fn7, Decl(instanceOfAssignability.ts, 67, 1)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 69, 13)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + + if(x instanceof Array) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 69, 13)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 73, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 69, 13)) + } +} + +interface Alpha { a } +>Alpha : Symbol(Alpha, Decl(instanceOfAssignability.ts, 75, 1)) +>a : Symbol(a, Decl(instanceOfAssignability.ts, 77, 17)) + +interface Beta { b } +>Beta : Symbol(Beta, Decl(instanceOfAssignability.ts, 77, 21)) +>b : Symbol(b, Decl(instanceOfAssignability.ts, 78, 16)) + +interface Gamma { c } +>Gamma : Symbol(Gamma, Decl(instanceOfAssignability.ts, 78, 20)) +>c : Symbol(c, Decl(instanceOfAssignability.ts, 79, 17)) + +class ABC { a; b; c; } +>ABC : Symbol(ABC, Decl(instanceOfAssignability.ts, 79, 21)) +>a : Symbol(a, Decl(instanceOfAssignability.ts, 80, 11)) +>b : Symbol(b, Decl(instanceOfAssignability.ts, 80, 14)) +>c : Symbol(c, Decl(instanceOfAssignability.ts, 80, 17)) + +function fn8(x: Alpha|Beta|Gamma) { +>fn8 : Symbol(fn8, Decl(instanceOfAssignability.ts, 80, 22)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 81, 13)) +>Alpha : Symbol(Alpha, Decl(instanceOfAssignability.ts, 75, 1)) +>Beta : Symbol(Beta, Decl(instanceOfAssignability.ts, 77, 21)) +>Gamma : Symbol(Gamma, Decl(instanceOfAssignability.ts, 78, 20)) + + if(x instanceof ABC) { +>x : Symbol(x, Decl(instanceOfAssignability.ts, 81, 13)) +>ABC : Symbol(ABC, Decl(instanceOfAssignability.ts, 79, 21)) + + let y = x; +>y : Symbol(y, Decl(instanceOfAssignability.ts, 83, 5)) +>x : Symbol(x, Decl(instanceOfAssignability.ts, 81, 13)) + } +} + + + diff --git a/tests/baselines/reference/instanceOfAssignability.types b/tests/baselines/reference/instanceOfAssignability.types new file mode 100644 index 00000000000..12b2d326062 --- /dev/null +++ b/tests/baselines/reference/instanceOfAssignability.types @@ -0,0 +1,216 @@ +=== tests/cases/compiler/instanceOfAssignability.ts === +interface Base { +>Base : Base + + foo: string|number; +>foo : string | number + + optional?: number; +>optional : number +} + +// Derived1 is assignable to, but not a subtype of, Base +class Derived1 implements Base { +>Derived1 : Derived1 +>Base : Base + + foo: string; +>foo : string +} +// Derived2 is a subtype of Base that is not assignable to Derived1 +class Derived2 implements Base { +>Derived2 : Derived2 +>Base : Base + + foo: number; +>foo : number + + optional: number; +>optional : number +} + +class Animal { +>Animal : Animal + + move; +>move : any +} +class Mammal extends Animal { milk; } +>Mammal : Mammal +>Animal : Animal +>milk : any + +class Giraffe extends Mammal { neck; } +>Giraffe : Giraffe +>Mammal : Mammal +>neck : any + +function fn1(x: Array|Array|boolean) { +>fn1 : (x: number[] | string[] | boolean) => void +>x : number[] | string[] | boolean +>Array : T[] +>Array : T[] + + if(x instanceof Array) { +>x instanceof Array : boolean +>x : number[] | string[] | boolean +>Array : ArrayConstructor + + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; +>y : number[] | string[] +>x : number[] | string[] + } +} + +function fn2(x: Base) { +>fn2 : (x: Base) => void +>x : Base +>Base : Base + + if(x instanceof Derived1) { +>x instanceof Derived1 : boolean +>x : Base +>Derived1 : typeof Derived1 + + // 1.5: y: Base + // Want: y: Derived1 + let y = x; +>y : Derived1 +>x : Derived1 + } +} + +function fn3(x: Base|Derived1) { +>fn3 : (x: Base | Derived1) => void +>x : Base | Derived1 +>Base : Base +>Derived1 : Derived1 + + if(x instanceof Derived2) { +>x instanceof Derived2 : boolean +>x : Base | Derived1 +>Derived2 : typeof Derived2 + + // 1.5: y: Derived2 + // Want: Derived2 + let y = x; +>y : Derived2 +>x : Derived2 + } +} + +function fn4(x: Base|Derived2) { +>fn4 : (x: Base | Derived2) => void +>x : Base | Derived2 +>Base : Base +>Derived2 : Derived2 + + if(x instanceof Derived1) { +>x instanceof Derived1 : boolean +>x : Base | Derived2 +>Derived1 : typeof Derived1 + + // 1.5: y: {} + // Want: Derived1 + let y = x; +>y : Derived1 +>x : Derived1 + } +} + +function fn5(x: Derived1) { +>fn5 : (x: Derived1) => void +>x : Derived1 +>Derived1 : Derived1 + + if(x instanceof Derived2) { +>x instanceof Derived2 : boolean +>x : Derived1 +>Derived2 : typeof Derived2 + + // 1.5: y: Derived1 + // Want: ??? + let y = x; +>y : Derived1 +>x : Derived1 + } +} + +function fn6(x: Animal|Mammal) { +>fn6 : (x: Animal | Mammal) => void +>x : Animal | Mammal +>Animal : Animal +>Mammal : Mammal + + if(x instanceof Giraffe) { +>x instanceof Giraffe : boolean +>x : Animal | Mammal +>Giraffe : typeof Giraffe + + // 1.5: y: Derived1 + // Want: ??? + let y = x; +>y : Giraffe +>x : Giraffe + } +} + +function fn7(x: Array|Array) { +>fn7 : (x: number[] | string[]) => void +>x : number[] | string[] +>Array : T[] +>Array : T[] + + if(x instanceof Array) { +>x instanceof Array : boolean +>x : number[] | string[] +>Array : ArrayConstructor + + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; +>y : number[] | string[] +>x : number[] | string[] + } +} + +interface Alpha { a } +>Alpha : Alpha +>a : any + +interface Beta { b } +>Beta : Beta +>b : any + +interface Gamma { c } +>Gamma : Gamma +>c : any + +class ABC { a; b; c; } +>ABC : ABC +>a : any +>b : any +>c : any + +function fn8(x: Alpha|Beta|Gamma) { +>fn8 : (x: Alpha | Beta | Gamma) => void +>x : Alpha | Beta | Gamma +>Alpha : Alpha +>Beta : Beta +>Gamma : Gamma + + if(x instanceof ABC) { +>x instanceof ABC : boolean +>x : Alpha | Beta | Gamma +>ABC : typeof ABC + + let y = x; +>y : ABC +>x : ABC + } +} + + + diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index bd8b2048045..7f1cc88e2a2 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -29,15 +29,7 @@ tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/compiler/intTypeCheck.ts(141,5): error TS2322: Type 'Object' is not assignable to type 'i4'. - Index signature is missing in type 'Object'. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/compiler/intTypeCheck.ts(143,5): error TS2322: Type 'Base' is not assignable to type 'i4'. - Index signature is missing in type 'Base'. -tests/cases/compiler/intTypeCheck.ts(145,5): error TS2322: Type '() => void' is not assignable to type 'i4'. - Index signature is missing in type '() => void'. -tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. - Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -73,21 +65,13 @@ tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/compiler/intTypeCheck.ts(197,5): error TS2322: Type 'Object' is not assignable to type 'i8'. - Index signature is missing in type 'Object'. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/compiler/intTypeCheck.ts(199,5): error TS2322: Type 'Base' is not assignable to type 'i8'. - Index signature is missing in type 'Base'. -tests/cases/compiler/intTypeCheck.ts(201,5): error TS2322: Type '() => void' is not assignable to type 'i8'. - Index signature is missing in type '() => void'. -tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. - Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -==== tests/cases/compiler/intTypeCheck.ts (69 errors) ==== +==== tests/cases/compiler/intTypeCheck.ts (61 errors) ==== interface i1 { //Property Signatures p; @@ -287,27 +271,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj33: i4; var obj34: i4 = {}; var obj35: i4 = new Object(); - ~~~~~ -!!! error TS2322: Type 'Object' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Object'. var obj36: i4 = new obj33; ~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var obj37: i4 = new Base; - ~~~~~ -!!! error TS2322: Type 'Base' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Base'. var obj38: i4 = null; var obj39: i4 = function () { }; - ~~~~~ -!!! error TS2322: Type '() => void' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type '() => void'. //var obj40: i4 = function foo() { }; var obj41: i4 = anyVar; var obj42: i4 = new anyVar; - ~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -421,27 +393,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj77: i8; var obj78: i8 = {}; var obj79: i8 = new Object(); - ~~~~~ -!!! error TS2322: Type 'Object' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Object'. var obj80: i8 = new obj77; ~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var obj81: i8 = new Base; - ~~~~~ -!!! error TS2322: Type 'Base' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Base'. var obj82: i8 = null; var obj83: i8 = function () { }; - ~~~~~ -!!! error TS2322: Type '() => void' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type '() => void'. //var obj84: i8 = function foo() { }; var obj85: i8 = anyVar; var obj86: i8 = new anyVar; - ~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ diff --git a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt index 95adbbf6717..138f3d92096 100644 --- a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt @@ -18,11 +18,9 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(60,15): error TS2430: Interface 'Derived5' incorrectly extends interface 'Base1'. Types of property 'x' are incompatible. Type 'T' is not assignable to type '{ a: T; }'. - Property 'a' is missing in type '{}'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(60,15): error TS2430: Interface 'Derived5' incorrectly extends interface 'Base2'. Types of property 'x' are incompatible. Type 'T' is not assignable to type '{ b: T; }'. - Property 'b' is missing in type '{}'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts (6 errors) ==== @@ -111,12 +109,10 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa !!! error TS2430: Interface 'Derived5' incorrectly extends interface 'Base1'. !!! error TS2430: Types of property 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type '{ a: T; }'. -!!! error TS2430: Property 'a' is missing in type '{}'. ~~~~~~~~ !!! error TS2430: Interface 'Derived5' incorrectly extends interface 'Base2'. !!! error TS2430: Types of property 'x' are incompatible. !!! error TS2430: Type 'T' is not assignable to type '{ b: T; }'. -!!! error TS2430: Property 'b' is missing in type '{}'. x: T; } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0c4b95214b0..3ec718f3b25 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt index de5cb97586c..749e86116e8 100644 --- a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt +++ b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt @@ -1,7 +1,7 @@ -error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. -!!! error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesDeclaration.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt index 68b2747cf6b..337fcb16ba3 100644 --- a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt +++ b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt @@ -1,7 +1,7 @@ -error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. -!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesNoEmitOnError.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt index 8234ba94585..7d16ac94666 100644 --- a/tests/baselines/reference/isolatedModulesOut.errors.txt +++ b/tests/baselines/reference/isolatedModulesOut.errors.txt @@ -1,8 +1,8 @@ -error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. -!!! error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/file1.ts (0 errors) ==== export var x; diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 3920dc1cef4..fae627e9c95 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 06e38c57af4..fefeaced83f 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index e16fe5255e4..fd00059449a 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index b8709197829..8271e564f9e 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 17ac6a1feac..d4f2949e24f 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 468866ca324..9e38c52ad70 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 6f0d347d9b4..523d81cde2d 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4608, 1), Decl(lib.d.ts, 4631, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 10225e183e6..d3a7f4fb1d7 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 86c46812688..efb88d2e608 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index ae99a4b5255..52f5f2d0b17 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index c4a2459e262..03099b124c9 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index c2fce062fb0..c18c9095f50 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index cdc7bb3e2bc..906e8288af0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index e4d1b508bb5..e25374c80a8 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index bd6760dd0aa..1856d1bb682 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index d0bc9790752..c68550b7fa7 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index a7e5d7b8919..874a034631d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 67b9e9e500d..0f84a0e1cbb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 0c3c11c84f4..6f329329431 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 03faf4b593e..01a0112b026 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js index 0b402b43de2..0a493006dc6 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.js +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -29,21 +29,18 @@ var foo = (function () { return foo; })(); var x; -x = {test}: }; +x = {test} }; x = ; -x = hello {} }; +x = hello {} } -x = }>hello}/>; +x = }>hello}/> -x = }>hello{}}; +x = }>hello{}} x = x, x = ; {{/foo/.test(x) ? : }} : -} - - -}}/>; +}}}/>; diff --git a/tests/baselines/reference/jsxHash.js b/tests/baselines/reference/jsxHash.js new file mode 100644 index 00000000000..04409a56eea --- /dev/null +++ b/tests/baselines/reference/jsxHash.js @@ -0,0 +1,26 @@ +//// [jsxHash.tsx] +var t02 = {0}#; +var t03 = #{0}; +var t04 = #{0}#; +var t05 = #; +var t06 = #; +var t07 = ##; +var t08 = #; +var t09 = ##; +var t10 = #; +var t11 = #; +var t12 = #; + + +//// [jsxHash.jsx] +var t02 = {0}#; +var t03 = #{0}; +var t04 = #{0}#; +var t05 = #; +var t06 = #; +var t07 = ##; +var t08 = #; +var t09 = ##; +var t10 = #; +var t11 = #; +var t12 = #; diff --git a/tests/baselines/reference/jsxHash.symbols b/tests/baselines/reference/jsxHash.symbols new file mode 100644 index 00000000000..8a6ad0849f0 --- /dev/null +++ b/tests/baselines/reference/jsxHash.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/jsxHash.tsx === +var t02 = {0}#; +>t02 : Symbol(t02, Decl(jsxHash.tsx, 0, 3)) + +var t03 = #{0}; +>t03 : Symbol(t03, Decl(jsxHash.tsx, 1, 3)) + +var t04 = #{0}#; +>t04 : Symbol(t04, Decl(jsxHash.tsx, 2, 3)) + +var t05 = #; +>t05 : Symbol(t05, Decl(jsxHash.tsx, 3, 3)) + +var t06 = #; +>t06 : Symbol(t06, Decl(jsxHash.tsx, 4, 3)) + +var t07 = ##; +>t07 : Symbol(t07, Decl(jsxHash.tsx, 5, 3)) + +var t08 = #; +>t08 : Symbol(t08, Decl(jsxHash.tsx, 6, 3)) + +var t09 = ##; +>t09 : Symbol(t09, Decl(jsxHash.tsx, 7, 3)) + +var t10 = #; +>t10 : Symbol(t10, Decl(jsxHash.tsx, 8, 3)) + +var t11 = #; +>t11 : Symbol(t11, Decl(jsxHash.tsx, 9, 3)) + +var t12 = #; +>t12 : Symbol(t12, Decl(jsxHash.tsx, 10, 3)) + diff --git a/tests/baselines/reference/jsxHash.types b/tests/baselines/reference/jsxHash.types new file mode 100644 index 00000000000..6d413141ca6 --- /dev/null +++ b/tests/baselines/reference/jsxHash.types @@ -0,0 +1,89 @@ +=== tests/cases/compiler/jsxHash.tsx === +var t02 = {0}#; +>t02 : any +>{0}# : any +>a : any +>0 : number +>a : any + +var t03 = #{0}; +>t03 : any +>#{0} : any +>a : any +>0 : number +>a : any + +var t04 = #{0}#; +>t04 : any +>#{0}# : any +>a : any +>0 : number +>a : any + +var t05 = #; +>t05 : any +># : any +>a : any +> : any +>i : any +>i : any +>a : any + +var t06 = #; +>t06 : any +># : any +>a : any +> : any +>i : any +>i : any +>a : any + +var t07 = ##; +>t07 : any +>## : any +>a : any +># : any +>i : any +>i : any +>a : any + +var t08 = #; +>t08 : any +># : any +>a : any +> : any +>i : any +>i : any +>a : any + +var t09 = ##; +>t09 : any +>## : any +>a : any +> : any +>i : any +>i : any +>a : any + +var t10 = #; +>t10 : any +># : any +>a : any +> : any +>i : any +>a : any + +var t11 = #; +>t11 : any +># : any +>a : any +> : any +>i : any +>a : any + +var t12 = #; +>t12 : any +># : any +>a : any +>a : any + diff --git a/tests/baselines/reference/jsxImportInAttribute.symbols b/tests/baselines/reference/jsxImportInAttribute.symbols index 8481771f085..845001b22c0 100644 --- a/tests/baselines/reference/jsxImportInAttribute.symbols +++ b/tests/baselines/reference/jsxImportInAttribute.symbols @@ -9,6 +9,7 @@ let x = Test; // emit test_1.default ; // ? >attr : Symbol(unknown) +>Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types index 8dfbe292fe0..8dc5c370fa8 100644 --- a/tests/baselines/reference/jsxImportInAttribute.types +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -11,7 +11,7 @@ let x = Test; // emit test_1.default > : any >anything : any >attr : any ->Test : any +>Test : typeof Test === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index 3e2a10e9931..02bc56e823e 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -30,6 +30,7 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,10): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. @@ -43,6 +44,7 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,7): error TS2304: Cannot find name 'a'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. @@ -60,10 +62,8 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,18): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,29): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS1005: '{' expected. tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1109: Expression expected. @@ -148,6 +148,8 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 !!! error TS2304: Cannot find name 'a'. ~ !!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS1005: '>' expected. ~ @@ -177,6 +179,8 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002 !!! error TS2304: Cannot find name 'a'. ~ !!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS1003: Identifier expected. ; @@ -223,15 +227,11 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS17002
stuff
; ~ !!! error TS1005: '>' expected. - ~~~ -!!! error TS1109: Expression expected.
stuff
; ~~~~~ !!! error TS2304: Cannot find name 'props'. ~ !!! error TS1005: '>' expected. - ~~~ -!!! error TS1109: Expression expected. >; >; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index 13808cc29e0..daf344b08da 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -65,17 +65,17 @@ a['foo'] > ; ; var x =
one
two
;; var x =
one
/* intervening comment */ /* intervening comment */
two
;; -
{"str"};}; -, id="b" />; -
"app">; +{"str"}}; + id="b" />; +
>;
; -
stuff
{}...props}>; -
stuff
{}...props}>; +
stuff
...props}>; +
stuff
...props}>; >; >; ; ; }; - .../*hai*/asdf/>;; + /*hai*//*hai*/asdf/>;; diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index 9e382742f0d..1fe64cbfdd7 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -45,6 +45,9 @@ declare var hasOwnProperty:any;

{foo}
{bar}
+>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
@@ -56,6 +59,7 @@ declare var hasOwnProperty:any; {this.props.children} ; +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) @@ -64,6 +68,7 @@ declare var hasOwnProperty:any; >Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11)) ; +>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11)) var x = >x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) @@ -156,6 +161,7 @@ var x = ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; @@ -181,6 +187,7 @@ var x = >x : Symbol(unknown) >y : Symbol(unknown) >Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) Text; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) @@ -189,6 +196,7 @@ var x = >y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27)) >z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) >z : Symbol(unknown) +>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index db7ebf8d912..88c2c278e59 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -251,6 +251,7 @@ var x = >y : any ={2 } z />; +>2 : number >z : any Component : any >x : any >y : any +>2 : number ; > : any >Component : any >x : any >y : any +>2 : number >z : any ; > : any >Component : any >x : any +>1 : number >y : any @@ -306,6 +310,7 @@ var x = > : any >Component : any >x : any +>1 : number >y : any >z : any >z : any @@ -326,6 +331,7 @@ var x = >2 : number >z : any >z : any +>3 : number >Component : any diff --git a/tests/baselines/reference/jsxViaImport.errors.txt b/tests/baselines/reference/jsxViaImport.errors.txt new file mode 100644 index 00000000000..8fa22809a44 --- /dev/null +++ b/tests/baselines/reference/jsxViaImport.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/consumer.tsx(5,17): error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures. + + +==== tests/cases/compiler/consumer.tsx (1 errors) ==== + /// + import BaseComponent = require('BaseComponent'); + class TestComponent extends React.Component { + render() { + return ; + ~~~~~~~~~~~~~ +!!! error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures. + } + } + +==== tests/cases/compiler/component.d.ts (0 errors) ==== + + declare module JSX { + interface ElementAttributesProperty { props; } + } + declare module React { + class Component { } + } + declare module "BaseComponent" { + var base: React.Component; + export = base; + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsxViaImport.js b/tests/baselines/reference/jsxViaImport.js new file mode 100644 index 00000000000..6bf61af67f5 --- /dev/null +++ b/tests/baselines/reference/jsxViaImport.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/jsxViaImport.tsx] //// + +//// [component.d.ts] + +declare module JSX { + interface ElementAttributesProperty { props; } +} +declare module React { + class Component { } +} +declare module "BaseComponent" { + var base: React.Component; + export = base; +} + +//// [consumer.tsx] +/// +import BaseComponent = require('BaseComponent'); +class TestComponent extends React.Component { + render() { + return ; + } +} + + +//// [consumer.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/// +var BaseComponent = require('BaseComponent'); +var TestComponent = (function (_super) { + __extends(TestComponent, _super); + function TestComponent() { + _super.apply(this, arguments); + } + TestComponent.prototype.render = function () { + return ; + }; + return TestComponent; +})(React.Component); diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 04bc188e308..4540e35aaf4 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -187,8 +187,8 @@ var rc5 = a5 || a3; // void || number is void | number >a3 : number var rc6 = a6 || a3; // enum || number is number ->rc6 : E | number ->a6 || a3 : E | number +>rc6 : number +>a6 || a3 : number >a6 : E >a3 : number @@ -349,8 +349,8 @@ var rg2 = a2 || a6; // boolean || enum is boolean | enum >a6 : E var rg3 = a3 || a6; // number || enum is number ->rg3 : number | E ->a3 || a6 : number | E +>rg3 : number +>a3 || a6 : number >a3 : number >a6 : E diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index df8f6cac6db..f887ad7ae14 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -107,8 +107,8 @@ function fn3u : U var r3 = t || { a: '' }; ->r3 : T | { a: string; } ->t || { a: '' } : T | { a: string; } +>r3 : { a: string; } +>t || { a: '' } : { a: string; } >t : T >{ a: '' } : { a: string; } >a : string diff --git a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt index 7445ab85a54..e8649cfb567 100644 --- a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt +++ b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt @@ -1,11 +1,10 @@ -tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(7,30): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (3 errors) ==== +==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (2 errors) ==== function map(xs: T[], f: (x: T) => U) { var ys: U[] = []; xs.forEach(x => ys.push(f(x))); @@ -13,8 +12,6 @@ tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): e } var r0 = map([1, ""], (x) => x.toString()); - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. var r5 = map([1, ""], (x) => x.toString()); var r6 = map([1, ""], (x) => x.toString()); var r7 = map([1, ""], (x) => x.toString()); // error diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt new file mode 100644 index 00000000000..b7331a68271 --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + + +==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ==== + class George extends class { reset() { return this.y; } } { + ~ +!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.js b/tests/baselines/reference/missingPropertiesOfClassExpression.js new file mode 100644 index 00000000000..f427da20f0c --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.js @@ -0,0 +1,26 @@ +//// [missingPropertiesOfClassExpression.ts] +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} + + +//// [missingPropertiesOfClassExpression.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var George = (function (_super) { + __extends(George, _super); + function George() { + _super.call(this); + } + return George; +})((function () { + function class_1() { + } + class_1.prototype.reset = function () { return this.y; }; + return class_1; +})()); diff --git a/tests/baselines/reference/moduleResolutionNoResolve.js b/tests/baselines/reference/moduleResolutionNoResolve.js new file mode 100644 index 00000000000..9f0537a5ad5 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/moduleResolutionNoResolve.ts] //// + +//// [a.ts] + +import a = require('./b'); + +//// [b.ts] +export var c = ''; + + +//// [a.js] +//// [b.js] +exports.c = ''; diff --git a/tests/baselines/reference/moduleResolutionNoResolve.symbols b/tests/baselines/reference/moduleResolutionNoResolve.symbols new file mode 100644 index 00000000000..17ccfeab496 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : Symbol(a, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : Symbol(c, Decl(b.ts, 0, 10)) + diff --git a/tests/baselines/reference/moduleResolutionNoResolve.types b/tests/baselines/reference/moduleResolutionNoResolve.types new file mode 100644 index 00000000000..3e96ed2b197 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : typeof a + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : string +>'' : string + diff --git a/tests/baselines/reference/multipleDefaultExports01.errors.txt b/tests/baselines/reference/multipleDefaultExports01.errors.txt new file mode 100644 index 00000000000..7b49afe1a4e --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports01.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/es6/modules/m1.ts(11,1): error TS2300: Duplicate identifier 'default'. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'? + + +==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== + + export default class foo { + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + + } + + export default function bar() { + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. + + } + + var x = 10; + export default x; + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'default'. + +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'? \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js new file mode 100644 index 00000000000..e633cf69f55 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/es6/modules/multipleDefaultExports01.ts] //// + +//// [m1.ts] + +export default class foo { + +} + +export default function bar() { + +} + +var x = 10; +export default x; + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +//// [m1.js] +var foo = (function () { + function foo() { + } + return foo; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = foo; +function bar() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = bar; +var x = 10; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = x; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.errors.txt b/tests/baselines/reference/multipleDefaultExports02.errors.txt new file mode 100644 index 00000000000..51220ecfae2 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports02.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate function implementation. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default function foo() { + ~~~ +!!! error TS2393: Duplicate function implementation. + + } + + export default function bar() { + ~~~ +!!! error TS2393: Duplicate function implementation. + + } + +==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ==== + import Entity from "m1" + + Entity(); \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js new file mode 100644 index 00000000000..3d1b84ff6a6 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/es6/modules/multipleDefaultExports02.ts] //// + +//// [m1.ts] + +export default function foo() { + +} + +export default function bar() { + +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +//// [m1.js] +function foo() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = foo; +function bar() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = bar; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); diff --git a/tests/baselines/reference/multivar.errors.txt b/tests/baselines/reference/multivar.errors.txt index 931e61de5ae..44061b9d74c 100644 --- a/tests/baselines/reference/multivar.errors.txt +++ b/tests/baselines/reference/multivar.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. -tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. +tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. ==== tests/cases/compiler/multivar.ts (2 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in export var a, b2: number = 10, b; ~~ -!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. var m1; var a2, b22: number = 10, b222; var m3; @@ -28,7 +28,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in declare var d1, d2; var b2; ~~ -!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. declare var v1; } diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index 4bddb6a1f71..9144d725efb 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -8,7 +8,7 @@ regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) >forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) ->''.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>''.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index 81fd614cb0e..afe2ff7bd22 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -14,9 +14,9 @@ regexMatchList.forEach(match => ''.replace(match, '')); >match => ''.replace(match, '') : (match: string) => string >match : string >''.replace(match, '') : string ->''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >'' : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >match : string >'' : string diff --git a/tests/baselines/reference/nodeResolution1.js b/tests/baselines/reference/nodeResolution1.js new file mode 100644 index 00000000000..3516342e3b2 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/nodeResolution1.ts] //// + +//// [a.ts] + +export var x = 1; + +//// [b.ts] +import y = require("./a"); + +//// [a.js] +exports.x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution1.symbols b/tests/baselines/reference/nodeResolution1.symbols new file mode 100644 index 00000000000..0cc98206e90 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : Symbol(x, Decl(a.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution1.types b/tests/baselines/reference/nodeResolution1.types new file mode 100644 index 00000000000..4f29acfcc03 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : typeof y + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/nodeResolution2.js b/tests/baselines/reference/nodeResolution2.js new file mode 100644 index 00000000000..a5935461088 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution2.ts] //// + +//// [a.d.ts] + +export var x: number; + +//// [b.ts] +import y = require("a"); + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution2.symbols b/tests/baselines/reference/nodeResolution2.symbols new file mode 100644 index 00000000000..643d285e7b8 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : Symbol(x, Decl(a.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution2.types b/tests/baselines/reference/nodeResolution2.types new file mode 100644 index 00000000000..896af7f8bda --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/nodeResolution3.js b/tests/baselines/reference/nodeResolution3.js new file mode 100644 index 00000000000..6e0ec608323 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution3.ts] //// + +//// [index.d.ts] + +export var x: number; + +//// [a.ts] +import y = require("b"); + +//// [a.js] diff --git a/tests/baselines/reference/nodeResolution3.symbols b/tests/baselines/reference/nodeResolution3.symbols new file mode 100644 index 00000000000..0fca588676f --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : Symbol(y, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : Symbol(x, Decl(index.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution3.types b/tests/baselines/reference/nodeResolution3.types new file mode 100644 index 00000000000..82a1ccb27d3 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : typeof y + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 71e164d5d62..ff18160e9a5 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Index signatures are incompatible. - Type 'A | B | number' is not assignable to type 'A'. + Type 'A | number' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -54,9 +54,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'A | B | number' is not assignable to type 'A'. +!!! error TS2322: Type 'A | number' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index edb6d031b1f..c35e49f02a3 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. @@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 55cec857c70..d5add00ebaf 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,7 +31,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A | B; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } >x : A >a : A >b : B diff --git a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt index 91a92dbd54c..1f2f432c9da 100644 --- a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt +++ b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt @@ -5,9 +5,12 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec Types of property 'data' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(30,5): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'MyList' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(31,5): error TS2322: Type 'T' is not assignable to type 'U'. + Type 'List' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(41,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(42,5): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'MyList' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(43,5): error TS2322: Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(48,5): error TS2322: Type 'T' is not assignable to type 'List'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(50,5): error TS2322: Type 'T' is not assignable to type 'MyList'. @@ -54,9 +57,11 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'MyList' is not assignable to type 'T'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'List' is not assignable to type 'U'. var a: List; var b: MyList; @@ -72,6 +77,7 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'MyList' is not assignable to type 'T'. u = t; // was error, ok after constraint made illegal, doesn't matter ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties2.js b/tests/baselines/reference/objectTypesWithOptionalProperties2.js index cf0d113c244..e5ffbf09c10 100644 --- a/tests/baselines/reference/objectTypesWithOptionalProperties2.js +++ b/tests/baselines/reference/objectTypesWithOptionalProperties2.js @@ -42,5 +42,6 @@ var C2 = (function () { return C2; })(); var b = { - x: function () { }, 1: // error + x: function () { }, 1: // error + // error }; diff --git a/tests/baselines/reference/optionalParamArgsTest.errors.txt b/tests/baselines/reference/optionalParamArgsTest.errors.txt index 3c4d2e37be9..05fefa85065 100644 --- a/tests/baselines/reference/optionalParamArgsTest.errors.txt +++ b/tests/baselines/reference/optionalParamArgsTest.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/optionalParamArgsTest.ts(31,12): error TS2393: Duplicate function implementation. -tests/cases/compiler/optionalParamArgsTest.ts(35,12): error TS2393: Duplicate function implementation. -tests/cases/compiler/optionalParamArgsTest.ts(35,47): error TS1016: A required parameter cannot follow an optional parameter. +tests/cases/compiler/optionalParamArgsTest.ts(34,12): error TS2393: Duplicate function implementation. +tests/cases/compiler/optionalParamArgsTest.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(99,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(100,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(101,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -20,10 +20,9 @@ tests/cases/compiler/optionalParamArgsTest.ts(114,1): error TS2346: Supplied par tests/cases/compiler/optionalParamArgsTest.ts(115,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(116,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/optionalParamArgsTest.ts (23 errors) ==== +==== tests/cases/compiler/optionalParamArgsTest.ts (22 errors) ==== // Optional parameter and default argument tests // Key: @@ -58,13 +57,10 @@ tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied par ~~~~ !!! error TS2393: Duplicate function implementation. - // Negative test - // "Optional parameters may only be followed by other optional parameters" + // Uninitialized parameter makes the initialized one required public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; } ~~~~ !!! error TS2393: Duplicate function implementation. - ~~~~~~ -!!! error TS1016: A required parameter cannot follow an optional parameter. } class C2 extends C1 { diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js index 414f474598d..0c5a5d82814 100644 --- a/tests/baselines/reference/optionalParamArgsTest.js +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -31,8 +31,7 @@ class C1 { public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; } - // Negative test - // "Optional parameters may only be followed by other optional parameters" + // Uninitialized parameter makes the initialized one required public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; } } @@ -152,8 +151,7 @@ var C1 = (function () { if (C1M5A2 === void 0) { C1M5A2 = 0; } return C1M5A1 + C1M5A2; }; - // Negative test - // "Optional parameters may only be followed by other optional parameters" + // Uninitialized parameter makes the initialized one required C1.prototype.C1M5 = function (C1M5A1, C1M5A2, C1M5A3) { if (C1M5A2 === void 0) { C1M5A2 = 0; } return C1M5A1 + C1M5A2; diff --git a/tests/baselines/reference/out-flag.js.map b/tests/baselines/reference/out-flag.js.map index ec4c14aac2b..1d33d382eba 100644 --- a/tests/baselines/reference/out-flag.js.map +++ b/tests/baselines/reference/out-flag.js.map @@ -1,2 +1,2 @@ //// [out-flag.js.map] -{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count","MyClass.SetCount"],"mappings":"AAAA,eAAe;AAGf,AADA,oBAAoB;;IACpBA;IAYAC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;QAEzBG,EAAEA;IACNA,CAACA;IACLH,cAACA;AAADA,CAACA,AAZD,IAYC"} \ No newline at end of file +{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count","MyClass.SetCount"],"mappings":"AAAA,eAAe;AAEf,oBAAoB;AACpB;IAAAA;IAYAC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;QAEzBG,EAAEA;IACNA,CAACA;IACLH,cAACA;AAADA,CAACA,AAZD,IAYC"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag.sourcemap.txt b/tests/baselines/reference/out-flag.sourcemap.txt index 0e69e34d62f..397cfe346a3 100644 --- a/tests/baselines/reference/out-flag.sourcemap.txt +++ b/tests/baselines/reference/out-flag.sourcemap.txt @@ -19,25 +19,26 @@ sourceFile:out-flag.ts --- >>>// my class comments 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^-> 1-> > - >// my class comments > -2 > -3 >// my class comments -1->Emitted(2, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(2, 1) Source(3, 1) + SourceIndex(0) -3 >Emitted(2, 21) Source(3, 21) + SourceIndex(0) +2 >// my class comments +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 21) Source(3, 21) + SourceIndex(0) --- >>>var MyClass = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 1) Source(4, 1) + SourceIndex(0) +--- >>> function MyClass() { 1->^^^^ 2 > ^^-> -1-> - > +1-> 1->Emitted(4, 5) Source(4, 1) + SourceIndex(0) name (MyClass) --- >>> } diff --git a/tests/baselines/reference/out-flag2.js b/tests/baselines/reference/out-flag2.js new file mode 100644 index 00000000000..e2a30f169e3 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/out-flag2.ts] //// + +//// [a.ts] + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag2.js.map b/tests/baselines/reference/out-flag2.js.map new file mode 100644 index 00000000000..c1523e75784 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACDX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.sourcemap.txt b/tests/baselines/reference/out-flag2.sourcemap.txt new file mode 100644 index 00000000000..6a67e61bc91 --- /dev/null +++ b/tests/baselines/reference/out-flag2.sourcemap.txt @@ -0,0 +1,104 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(2, 5) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(3, 5) Source(2, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(2, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(4, 5) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(4, 13) Source(2, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(5, 1) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 2) Source(2, 12) + SourceIndex(0) name (A) +3 >Emitted(5, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(5, 6) Source(2, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(6, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(7, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(8, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(8, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(9, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(10, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(10, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(10, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.symbols b/tests/baselines/reference/out-flag2.symbols new file mode 100644 index 00000000000..1bca057c580 --- /dev/null +++ b/tests/baselines/reference/out-flag2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +class B { } +>B : Symbol(B, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/out-flag2.types b/tests/baselines/reference/out-flag2.types new file mode 100644 index 00000000000..5a13642f99f --- /dev/null +++ b/tests/baselines/reference/out-flag2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : A + +=== tests/cases/compiler/b.ts === +class B { } +>B : B + diff --git a/tests/baselines/reference/out-flag3.errors.txt b/tests/baselines/reference/out-flag3.errors.txt new file mode 100644 index 00000000000..6b7dda7c962 --- /dev/null +++ b/tests/baselines/reference/out-flag3.errors.txt @@ -0,0 +1,12 @@ +error TS5053: Option 'out' cannot be specified with option 'outFile'. + + +!!! error TS5053: Option 'out' cannot be specified with option 'outFile'. +==== tests/cases/compiler/a.ts (0 errors) ==== + + // --out and --outFile error + + class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + class B { } \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.js b/tests/baselines/reference/out-flag3.js new file mode 100644 index 00000000000..8327c3429d3 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/out-flag3.ts] //// + +//// [a.ts] + +// --out and --outFile error + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +// --out and --outFile error +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag3.js.map b/tests/baselines/reference/out-flag3.js.map new file mode 100644 index 00000000000..a52d66589c7 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA,4BAA4B;AAE5B;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACHX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.sourcemap.txt b/tests/baselines/reference/out-flag3.sourcemap.txt new file mode 100644 index 00000000000..c30c9f63020 --- /dev/null +++ b/tests/baselines/reference/out-flag3.sourcemap.txt @@ -0,0 +1,114 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>// --out and --outFile error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// --out and --outFile error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 29) Source(2, 29) + SourceIndex(0) +--- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > + > +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(4, 5) Source(4, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(4, 6) Source(4, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(5, 5) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 13) Source(4, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(6, 1) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(6, 2) Source(4, 12) + SourceIndex(0) name (A) +3 >Emitted(6, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(6, 6) Source(4, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(7, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(8, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(9, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(10, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(11, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(11, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(11, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(11, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols index 815f977d605..bc2bd0785b9 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols @@ -14,9 +14,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : Symbol(result, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 7)) ->message.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>message.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >message : Symbol(message, Decl(overloadResolutionOverNonCTLambdas.ts, 5, 16)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >match : Symbol(match, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 55)) >rest : Symbol(rest, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 61)) diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index f62bb4e8373..066015389d2 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -15,9 +15,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : string >message.replace(/\{(\d+)\}/g, function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; }) : string ->message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >message : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\{(\d+)\}/g : RegExp >function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; } : (match: string, ...rest: any[]) => any >match : string diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.js b/tests/baselines/reference/paramterDestrcuturingDeclaration.js new file mode 100644 index 00000000000..6920f22b0d4 --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.js @@ -0,0 +1,20 @@ +//// [paramterDestrcuturingDeclaration.ts] + +interface C { + ({p: name}): any; + new ({p: boolean}): any; +} + + +//// [paramterDestrcuturingDeclaration.js] + + +//// [paramterDestrcuturingDeclaration.d.ts] +interface C { + ({p: name}: { + p: any; + }): any; + new ({p: boolean}: { + p: any; + }): any; +} diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols b/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols new file mode 100644 index 00000000000..dd11b302eea --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/paramterDestrcuturingDeclaration.ts === + +interface C { +>C : Symbol(C, Decl(paramterDestrcuturingDeclaration.ts, 0, 0)) + + ({p: name}): any; +>p : Symbol(p) +>name : Symbol(name, Decl(paramterDestrcuturingDeclaration.ts, 2, 6)) + + new ({p: boolean}): any; +>p : Symbol(p) +>boolean : Symbol(boolean, Decl(paramterDestrcuturingDeclaration.ts, 3, 10)) +} + diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.types b/tests/baselines/reference/paramterDestrcuturingDeclaration.types new file mode 100644 index 00000000000..4b49ce22035 --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/paramterDestrcuturingDeclaration.ts === + +interface C { +>C : C + + ({p: name}): any; +>p : any +>name : any + + new ({p: boolean}): any; +>p : any +>boolean : any +} + diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 1423901a28f..61ec1a24ec5 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -149,8 +149,8 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : number >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? x => x : x => undefined : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -169,8 +169,8 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -191,8 +191,8 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -216,9 +216,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : number >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : ((x: number) => number) | ((x: number) => any) ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : ((x: number) => number) | ((x: number) => any) +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index 344933ea1fc..a055f2f1bbd 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parseRegularExpressionMixedWithComments.errors.txt b/tests/baselines/reference/parseRegularExpressionMixedWithComments.errors.txt new file mode 100644 index 00000000000..a6d63ce1754 --- /dev/null +++ b/tests/baselines/reference/parseRegularExpressionMixedWithComments.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(5,18): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(5,22): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(6,18): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(6,26): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts(6,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + +==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts (6 errors) ==== + var regex1 = / asdf /; + var regex2 = /**// asdf /; + var regex3 = /**///**/ asdf / // should be a comment line + 1; + var regex4 = /**// /**/asdf /; + ~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1109: Expression expected. + ~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var regex5 = /**// asdf/**/ /; + ~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~ +!!! error TS1109: Expression expected. + ~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/parseRegularExpressionMixedWithComments.js b/tests/baselines/reference/parseRegularExpressionMixedWithComments.js new file mode 100644 index 00000000000..c7aded33697 --- /dev/null +++ b/tests/baselines/reference/parseRegularExpressionMixedWithComments.js @@ -0,0 +1,14 @@ +//// [parseRegularExpressionMixedWithComments.ts] +var regex1 = / asdf /; +var regex2 = /**// asdf /; +var regex3 = /**///**/ asdf / // should be a comment line +1; +var regex4 = /**// /**/asdf /; +var regex5 = /**// asdf/**/ /; + +//// [parseRegularExpressionMixedWithComments.js] +var regex1 = / asdf /; +var regex2 = / asdf /; +var regex3 = 1; +var regex4 = / / * * /asdf /; +var regex5 = / asdf/ * * / /; diff --git a/tests/baselines/reference/parserSuperExpression1.js b/tests/baselines/reference/parserSuperExpression1.js index 0d312f79104..0d219afad37 100644 --- a/tests/baselines/reference/parserSuperExpression1.js +++ b/tests/baselines/reference/parserSuperExpression1.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - _super.foo.call(this); + _super.prototype.foo.call(this); }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - _super.foo.call(this); + _super.prototype.foo.call(this); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression2.js b/tests/baselines/reference/parserSuperExpression2.js index 7a77c28ef52..eb3c2c697e6 100644 --- a/tests/baselines/reference/parserSuperExpression2.js +++ b/tests/baselines/reference/parserSuperExpression2.js @@ -10,7 +10,7 @@ var C = (function () { function C() { } C.prototype.M = function () { - _super..call(this, 0); + _super.prototype..call(this, 0); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression4.js b/tests/baselines/reference/parserSuperExpression4.js index 46ffc65f57c..59ba63bb2cf 100644 --- a/tests/baselines/reference/parserSuperExpression4.js +++ b/tests/baselines/reference/parserSuperExpression4.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - _super.foo = 1; + _super.prototype.foo = 1; }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - _super.foo = 1; + _super.prototype.foo = 1; }; return C; })(); diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 5d97b2d7a01..f21959df892 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 69764d70b45..9f43ba7b006 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index c42bb3abb83..e3a3b1d5609 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index ba93afde837..ba0134e82a9 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index 4829677f516..970f8a0b753 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 793b925b382..29831fad7ef 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index e1b85f2a3b9..8322d312839 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index 05b002eb569..7c5dfbff7c6 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index 774eb2dcc4b..7ee5e7e6998 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserindenter.js b/tests/baselines/reference/parserindenter.js index 511e75ea135..a60eadc66a1 100644 --- a/tests/baselines/reference/parserindenter.js +++ b/tests/baselines/reference/parserindenter.js @@ -890,7 +890,7 @@ var Formatting; return result; }; Indenter.GetIndentSizeFromIndentText = function (indentText, editorOptions) { - return GetIndentSizeFromText(indentText, editorOptions, false); + return GetIndentSizeFromText(indentText, editorOptions, /*includeNonIndentChars:*/ false); }; Indenter.GetIndentSizeFromText = function (text, editorOptions, includeNonIndentChars) { var indentSize = 0; @@ -1174,7 +1174,7 @@ var Formatting; return null; var origIndentText = this.snapshot.GetText(new Span(indentEditInfo.OrigIndentPosition, indentEditInfo.OrigIndentLength())); var newIndentText = indentEditInfo.Indentation(); - var origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, true); + var origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, /*includeNonIndentChars*/ true); var newIndentSize = Indenter.GetIndentSizeFromIndentText(newIndentText, this.editorOptions); // Check the child's position whether it's before the parent position // if so indent the child based on the first token on the line as opposed to the parent position diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index bafcc39f48d..9cd0dd7b0cf 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index bafcc39f48d..9cd0dd7b0cf 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,6 +1,6 @@ error TS6053: File 'a.ts' not found. -error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. +error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. !!! error TS6053: File 'a.ts' not found. -!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.tsx', '.ts', '.d.ts'. \ No newline at end of file +!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt index 401347e92f1..8e555fb23f2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map index af309c1684b..1602fe4d4e0 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt index 8d9c30d6288..240277bfc70 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/mapRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map index af309c1684b..1602fe4d4e0 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 44306f12661..1a530c850e2 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index af309c1684b..1602fe4d4e0 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 55483177e5b..511832f1de0 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index af309c1684b..1602fe4d4e0 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index d1972c6fac7..a1d591a0497 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 8a778d7b74b..133c266cc9e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index d1972c6fac7..a1d591a0497 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index dfc6d1e756f..0b573b627cf 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index eb72bfc3c02..4f87045fd25 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 534b9497bda..a9e2e3f0e3c 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index eb72bfc3c02..4f87045fd25 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 71ac2234142..c4c267ec395 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt index 9d64326a562..f630a92b4a9 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/test.js.map index b6fc8f25627..05ee1332d71 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt index 9d64326a562..f630a92b4a9 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/mapRootAbsolutePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/test.js.map index b6fc8f25627..05ee1332d71 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt index d83cb1fe788..74b8b777ec3 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index b6fc8f25627..05ee1332d71 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt index d83cb1fe788..74b8b777ec3 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/mapRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index b6fc8f25627..05ee1332d71 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map index 8df103744b5..37b77beb154 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt index 66573712ce7..69830c04b56 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/amd/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map index 8df103744b5..37b77beb154 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt index 66573712ce7..69830c04b56 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathMultifolderSpecifyOutputFile/node/mapRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt index ad89f7cfe86..86dae9982ec 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/test.js.map index 08a7411226a..230b0e33817 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt index ad89f7cfe86..86dae9982ec 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/mapRootAbsolutePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/test.js.map index 08a7411226a..230b0e33817 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt index fbca4c774c7..84f8b2e886a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 08a7411226a..230b0e33817 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt index fbca4c774c7..84f8b2e886a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/mapRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 08a7411226a..230b0e33817 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map index f358b98d465..b7b29ed1cf8 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt index ca11421c733..e020abba5a5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/amd/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map index f358b98d465..b7b29ed1cf8 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt index ca11421c733..e020abba5a5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSimpleSpecifyOutputFile/node/mapRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt index 2c8142a51ef..702f520b4a6 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/test.js.map index 1d5372ad9c9..cba32efbabe 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt index 2c8142a51ef..702f520b4a6 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/mapRootAbsolutePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/test.js.map index 1d5372ad9c9..cba32efbabe 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt index b87a91089b3..68ca3d32ac9 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 1d5372ad9c9..cba32efbabe 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt index b87a91089b3..68ca3d32ac9 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/mapRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 1d5372ad9c9..cba32efbabe 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map index 6882b70c389..91ea14b3da4 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt index cfa708b107d..a82ab38507b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/amd/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map index 6882b70c389..91ea14b3da4 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt index cfa708b107d..a82ab38507b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootAbsolutePathSubfolderSpecifyOutputFile/node/mapRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt index c4ea7bd2123..e6c67f2d66a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map index 515473b17f7..3fcfc31e4d1 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt index 0eed3e7d5ba..ad208f9375c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/mapRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/test.js.map index 515473b17f7..3fcfc31e4d1 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 1fdab4bbb56..181b1b84b5f 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 515473b17f7..3fcfc31e4d1 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 129d326ecac..4230c8e6366 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 515473b17f7..3fcfc31e4d1 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 9d7accaa452..b63911a2bc8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index e5fd70c6434..f1cc6df9de8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 9d7accaa452..b63911a2bc8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 2fc592160a1..0a373a20359 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/node/mapRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 1b716998db3..630508cb9f8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 78467c99ecc..fd08e128cfe 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 1b716998db3..630508cb9f8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../outputdir_mixed_subfolder/ref/m1.ts","../outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 7603a4ca2b0..eb9ad2993b2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt index a0f444928ea..f820fb19c65 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/test.js.map index b6c5ca84681..ee5a589cb62 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt index a0f444928ea..f820fb19c65 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/mapRootRelativePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/test.js.map index b6c5ca84681..ee5a589cb62 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt index ff91d92f2c9..f9b0d9fd57e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index b6c5ca84681..ee5a589cb62 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt index ff91d92f2c9..f9b0d9fd57e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/mapRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index b6c5ca84681..ee5a589cb62 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map index fdcfeeef82a..03cefb2f8d3 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index ebe3cd999ae..d173bd36fb2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/amd/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map index fdcfeeef82a..03cefb2f8d3 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_multifolder/ref/m1.ts","../outputdir_multifolder_ref/m2.ts","../outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index ebe3cd999ae..d173bd36fb2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathMultifolderSpecifyOutputFile/node/mapRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/mapRootRelativePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/mapRootRelativePathSimpleNoOutdir.sourcemap.txt index 1af999bf589..880f12ff461 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/mapRootRelativePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/mapRootRelativePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/test.js.map index ee9a236558d..bb435749048 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/mapRootRelativePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/mapRootRelativePathSimpleNoOutdir.sourcemap.txt index 1af999bf589..880f12ff461 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/mapRootRelativePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/mapRootRelativePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/test.js.map index ee9a236558d..bb435749048 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt index f62798ba3fe..3ac5b590640 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ee9a236558d..bb435749048 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt index f62798ba3fe..3ac5b590640 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/mapRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index ee9a236558d..bb435749048 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map index e2b612e5851..11bf13c6ac8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/m1.ts","../outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/m1.ts","../outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt index 0c75ab9d5e1..452ad2eb841 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/amd/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map index e2b612e5851..11bf13c6ac8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/m1.ts","../outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_simple/m1.ts","../outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt index 0c75ab9d5e1..452ad2eb841 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSimpleSpecifyOutputFile/node/mapRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt index 3ec9d9c435c..87f1e589a12 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/test.js.map index f1475afcba7..fe7aaf2252b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt index 3ec9d9c435c..87f1e589a12 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/mapRootRelativePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/test.js.map index f1475afcba7..fe7aaf2252b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt index 0ff54843266..f68430b295d 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index f1475afcba7..fe7aaf2252b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt index 0ff54843266..f68430b295d 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/mapRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index f1475afcba7..fe7aaf2252b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map index 1760e9f4124..9e7077cbe25 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/ref/m1.ts","../outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/ref/m1.ts","../outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt index 3bad00b19d7..8c4bedb4b30 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/amd/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map index 1760e9f4124..9e7077cbe25 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/ref/m1.ts","../outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_subfolder/ref/m1.ts","../outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt index 3bad00b19d7..8c4bedb4b30 100644 --- a/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/mapRootRelativePathSubfolderSpecifyOutputFile/node/mapRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt index c13865cf8f3..7c797a023a2 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/test.js.map index 5b6ec16659f..767d260e0b8 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt index 0b663f820bb..6aecdcd084a 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/maprootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/test.js.map index 5b6ec16659f..767d260e0b8 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index e0f4f03c27a..06b8e768334 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 5b6ec16659f..767d260e0b8 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 96f7d6f45aa..468e5d2338b 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 5b6ec16659f..767d260e0b8 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 420891e5019..df57785d945 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 26d86253ec1..0c806666ef0 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 420891e5019..df57785d945 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 0510b7e7e33..aede30c6f73 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index e0b70849bc1..e7042dca90a 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 00fddd7206e..5637274312d 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index e0b70849bc1..e7042dca90a 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 9d9bdbe17a2..fa3d5513061 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/maprootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/maprootUrlMultifolderNoOutdir.sourcemap.txt index a2fc3dfe05e..ceda6b4c058 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/maprootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/maprootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/test.js.map index 06903d6fc51..04ab805bfcb 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/maprootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/maprootUrlMultifolderNoOutdir.sourcemap.txt index a2fc3dfe05e..ceda6b4c058 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/maprootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/maprootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/test.js.map index 06903d6fc51..04ab805bfcb 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 3bbfa8afdfa..2bf3e659118 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 06903d6fc51..04ab805bfcb 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 3bbfa8afdfa..2bf3e659118 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 06903d6fc51..04ab805bfcb 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map index 06f3e72443d..aecd97d5136 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt index f889da36fe6..344b620620d 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/amd/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map index 06f3e72443d..aecd97d5136 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_multifolder/ref/m1.ts","file:///tests/cases/projects/outputdir_multifolder_ref/m2.ts","file:///tests/cases/projects/outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt index f889da36fe6..344b620620d 100644 --- a/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlMultifolderSpecifyOutputFile/node/maprootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:file:///tests/cases/projects/outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/maprootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/maprootUrlSimpleNoOutdir.sourcemap.txt index 173dec77069..f13225988bd 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/maprootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/maprootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/test.js.map index 5b13c1897d9..ede8f059f00 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/maprootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/maprootUrlSimpleNoOutdir.sourcemap.txt index 173dec77069..f13225988bd 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/maprootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/maprootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/test.js.map index 5b13c1897d9..ede8f059f00 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index e1589c0feff..c5c7205d894 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 5b13c1897d9..ede8f059f00 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index e1589c0feff..c5c7205d894 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/maprootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 5b13c1897d9..ede8f059f00 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map index b1aa6b79fb6..29ba590802a 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/m1.ts","file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/m1.ts","file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt index fb91eae1254..27d691b2b10 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/amd/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/bin/test.js.map index b1aa6b79fb6..29ba590802a 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/m1.ts","file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_simple/m1.ts","file:///tests/cases/projects/outputdir_simple/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt index fb91eae1254..27d691b2b10 100644 --- a/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSimpleSpecifyOutputFile/node/maprootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:file:///tests/cases/projects/outputdir_simple/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/maprootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/maprootUrlSubfolderNoOutdir.sourcemap.txt index 1d778de19b1..7f311cb64ee 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/maprootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/maprootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/test.js.map index ec6296f1323..5883b6aac3f 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/maprootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/maprootUrlSubfolderNoOutdir.sourcemap.txt index 1d778de19b1..7f311cb64ee 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/maprootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/maprootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/test.js.map index ec6296f1323..5883b6aac3f 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index 003ceee4d93..5f992db6323 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ec6296f1323..5883b6aac3f 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index 003ceee4d93..5f992db6323 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index ec6296f1323..5883b6aac3f 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map index e56b1937c6d..25ed0e8fc92 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 5f63c0e5142..b8a52baa41e 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/amd/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map index e56b1937c6d..25ed0e8fc92 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_subfolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 5f63c0e5142..b8a52baa41e 100644 --- a/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlSubfolderSpecifyOutputFile/node/maprootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:file:///tests/cases/projects/outputdir_subfolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt index 679505e8648..d7a3195e995 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt index 341a676141d..fe1ebdb1cc9 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/maprootUrlsourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 39fe2de604c..6f2bf783957 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 4483b21610f..eff1de8b039 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 156e391d669..7a70d18105c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 877c5b5035c..49c44cde80e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 156e391d669..7a70d18105c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index a15e54dd069..d54d4d6245e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index c5ec380afae..53e31e30260 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index b75fe639eb9..7793026dd6e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index c5ec380afae..53e31e30260 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 7a54e211028..a6deca12207 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt index 96940f59a3f..8bcabc44e3a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt index 96940f59a3f..8bcabc44e3a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/maprootUrlsourcerootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 5a945f4c71d..e2d9eaa8dda 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 5a945f4c71d..e2d9eaa8dda 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map index df7254bd000..2e0ee57fe05 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt index 4e24018adaf..f64fa277957 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map index df7254bd000..2e0ee57fe05 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt index 4e24018adaf..f64fa277957 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile/node/maprootUrlsourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt index 6be1df8d85d..a3179d120d8 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt index 6be1df8d85d..a3179d120d8 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/maprootUrlsourcerootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index 90059c54016..232cdca7916 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index 90059c54016..232cdca7916 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map index a107f15c1bf..f1c6e3bd1b7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt index 6ce817a2afc..8d22ea01f16 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/amd/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map index a107f15c1bf..f1c6e3bd1b7 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt index 6ce817a2afc..8d22ea01f16 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSimpleSpecifyOutputFile/node/maprootUrlsourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt index e6031c87b2b..e697e24c64d 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt index e6031c87b2b..e697e24c64d 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/maprootUrlsourcerootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index aff09cc2ec5..50bebc38cbe 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index aff09cc2ec5..50bebc38cbe 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map index 6e45ee8da7d..e80a550275c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 8a2e3c01e10..b885327d186 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/amd/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map index 6e45ee8da7d..e80a550275c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 8a2e3c01e10..b885327d186 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile/node/maprootUrlsourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/rootDirectory/amd/outdir/simple/FolderB/fileB.js.map b/tests/baselines/reference/project/rootDirectory/amd/outdir/simple/FolderB/fileB.js.map index d1c844d3247..79496de73d9 100644 --- a/tests/baselines/reference/project/rootDirectory/amd/outdir/simple/FolderB/fileB.js.map +++ b/tests/baselines/reference/project/rootDirectory/amd/outdir/simple/FolderB/fileB.js.map @@ -1 +1 @@ -{"version":3,"file":"fileB.js","sourceRoot":"","sources":["../../../FolderA/FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AACA,AADA,wCAAwC;;IACxCA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file +{"version":3,"file":"fileB.js","sourceRoot":"","sources":["../../../FolderA/FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AAAA,wCAAwC;AACxC;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/rootDirectory/amd/rootDirectory.sourcemap.txt b/tests/baselines/reference/project/rootDirectory/amd/rootDirectory.sourcemap.txt index 83ee3b40181..0833854ab17 100644 --- a/tests/baselines/reference/project/rootDirectory/amd/rootDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/rootDirectory/amd/rootDirectory.sourcemap.txt @@ -66,23 +66,24 @@ sourceFile:../../../FolderA/FolderB/fileB.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) --- >>>var B = (function () { ->>> function B() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/project/rootDirectory/node/outdir/simple/FolderB/fileB.js.map b/tests/baselines/reference/project/rootDirectory/node/outdir/simple/FolderB/fileB.js.map index d1c844d3247..79496de73d9 100644 --- a/tests/baselines/reference/project/rootDirectory/node/outdir/simple/FolderB/fileB.js.map +++ b/tests/baselines/reference/project/rootDirectory/node/outdir/simple/FolderB/fileB.js.map @@ -1 +1 @@ -{"version":3,"file":"fileB.js","sourceRoot":"","sources":["../../../FolderA/FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AACA,AADA,wCAAwC;;IACxCA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file +{"version":3,"file":"fileB.js","sourceRoot":"","sources":["../../../FolderA/FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AAAA,wCAAwC;AACxC;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/rootDirectory/node/rootDirectory.sourcemap.txt b/tests/baselines/reference/project/rootDirectory/node/rootDirectory.sourcemap.txt index 83ee3b40181..0833854ab17 100644 --- a/tests/baselines/reference/project/rootDirectory/node/rootDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/rootDirectory/node/rootDirectory.sourcemap.txt @@ -66,23 +66,24 @@ sourceFile:../../../FolderA/FolderB/fileB.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) --- >>>var B = (function () { ->>> function B() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/outdir/simple/FolderB/fileB.js.map b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/outdir/simple/FolderB/fileB.js.map index 16a45385420..41ef9567648 100644 --- a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/outdir/simple/FolderB/fileB.js.map +++ b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/outdir/simple/FolderB/fileB.js.map @@ -1 +1 @@ -{"version":3,"file":"fileB.js","sourceRoot":"SourceRootPath/","sources":["FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AACA,AADA,wCAAwC;;IACxCA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file +{"version":3,"file":"fileB.js","sourceRoot":"SourceRootPath/","sources":["FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AAAA,wCAAwC;AACxC;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/rootDirectoryWithSourceRoot.sourcemap.txt b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/rootDirectoryWithSourceRoot.sourcemap.txt index 7c5843bdd34..c0f24c52650 100644 --- a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/rootDirectoryWithSourceRoot.sourcemap.txt +++ b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/amd/rootDirectoryWithSourceRoot.sourcemap.txt @@ -66,23 +66,24 @@ sourceFile:FolderB/fileB.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) --- >>>var B = (function () { ->>> function B() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/outdir/simple/FolderB/fileB.js.map b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/outdir/simple/FolderB/fileB.js.map index 16a45385420..41ef9567648 100644 --- a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/outdir/simple/FolderB/fileB.js.map +++ b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/outdir/simple/FolderB/fileB.js.map @@ -1 +1 @@ -{"version":3,"file":"fileB.js","sourceRoot":"SourceRootPath/","sources":["FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AACA,AADA,wCAAwC;;IACxCA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file +{"version":3,"file":"fileB.js","sourceRoot":"SourceRootPath/","sources":["FolderB/fileB.ts"],"names":["B","B.constructor"],"mappings":"AAAA,wCAAwC;AACxC;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/rootDirectoryWithSourceRoot.sourcemap.txt b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/rootDirectoryWithSourceRoot.sourcemap.txt index 7c5843bdd34..c0f24c52650 100644 --- a/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/rootDirectoryWithSourceRoot.sourcemap.txt +++ b/tests/baselines/reference/project/rootDirectoryWithSourceRoot/node/rootDirectoryWithSourceRoot.sourcemap.txt @@ -66,23 +66,24 @@ sourceFile:FolderB/fileB.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 41) Source(1, 41) + SourceIndex(0) --- >>>var B = (function () { ->>> function B() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(2, 1) + SourceIndex(0) name (B) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt index 154daaa4a70..7e234d178b8 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map index 9bf8cc49759..b5e6eec3623 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt index 95d78aa3a6f..f0b41e615ae 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/sourceRootAbsolutePathMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map index 9bf8cc49759..b5e6eec3623 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 9bf8cc49759..b5e6eec3623 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 7197c780765..999019984d6 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 9bf8cc49759..b5e6eec3623 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 68ab2e1cb0e..9ed3d1262fa 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 63116c3c3ec..65bbb0e67c2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 7579aa9cc1c..bbad2c102f9 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 63116c3c3ec..65bbb0e67c2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 8fe4fb35089..c409dc99f14 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index 81d49818901..820efe6d9d1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 1a094439574..8536097d111 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index 81d49818901..820efe6d9d1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 1b485f8a450..47e9f1da73a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt index 06c05bb438b..b7293d81f54 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/test.js.map index 54f77cba804..da7206b4e32 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt index 06c05bb438b..b7293d81f54 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/sourceRootAbsolutePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/test.js.map index 54f77cba804..da7206b4e32 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 54f77cba804..da7206b4e32 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt index 0cd80fd563d..a76377a99e4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 54f77cba804..da7206b4e32 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt index 0cd80fd563d..a76377a99e4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory/node/sourceRootAbsolutePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map index 6baf87e6a0a..9ce443017eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt index c686916fecf..23f41f64947 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/amd/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map index 6baf87e6a0a..9ce443017eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_multifolder/src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt index c686916fecf..23f41f64947 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMultifolderSpecifyOutputFile/node/sourceRootAbsolutePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt index 937975a41dc..0087d5d6716 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/test.js.map index 2c82359c39e..68302f9245b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt index 937975a41dc..0087d5d6716 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/sourceRootAbsolutePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/test.js.map index 2c82359c39e..68302f9245b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 2c82359c39e..68302f9245b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt index b94aa72552f..a0c7d8cd976 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/amd/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 2c82359c39e..68302f9245b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt index b94aa72552f..a0c7d8cd976 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputDirectory/node/sourceRootAbsolutePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map index 725dab29806..28168d6c0ce 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt index 1091dae5c06..f4897f2cd52 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/amd/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map index 725dab29806..28168d6c0ce 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_simple/src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt index 1091dae5c06..f4897f2cd52 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSimpleSpecifyOutputFile/node/sourceRootAbsolutePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt index e76f86d4edf..9d5c143cfd4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/test.js.map index 7aecf7bb797..9979f6eb7d5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt index e76f86d4edf..9d5c143cfd4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/sourceRootAbsolutePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/test.js.map index 7aecf7bb797..9979f6eb7d5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 7aecf7bb797..9979f6eb7d5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt index e8ad9ce990c..63af6359f7e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/amd/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 7aecf7bb797..9979f6eb7d5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt index e8ad9ce990c..63af6359f7e 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory/node/sourceRootAbsolutePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map index 9d1c6c21871..d11b23b98c4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt index d51d030afc4..6a0176bdacd 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/amd/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map index 9d1c6c21871..d11b23b98c4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_subfolder/src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt index d51d030afc4..6a0176bdacd 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootAbsolutePathSubfolderSpecifyOutputFile/node/sourceRootAbsolutePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt index 4492ea156cd..a144760b69f 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map index 7b83f21b715..6014ca91598 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt index 18997be9365..64ebd330860 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/sourceRootRelativePathMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/test.js.map index 7b83f21b715..6014ca91598 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 7b83f21b715..6014ca91598 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 4af0f38468e..a8377701181 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 7b83f21b715..6014ca91598 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index bdfda8e946b..d8857daae5c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index f3b07b196ea..86afcf32e25 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 9bf843435cb..94b86ffdde1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index f3b07b196ea..86afcf32e25 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt index 59f5f96fc76..12a6fdbc6dd 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index bae3da16f51..13b958b1025 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index d4f1ba4f5aa..11e34ee5a2e 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index bae3da16f51..13b958b1025 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 47a5afc6d80..5b9ec51c270 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt index 88e6b10a246..20c4a628b79 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/test.js.map index 3f2781e7135..1c3b0105b5f 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt index 88e6b10a246..20c4a628b79 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/sourceRootRelativePathMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/test.js.map index 3f2781e7135..1c3b0105b5f 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 3f2781e7135..1c3b0105b5f 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt index 939e34eb98b..325718e37e1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/amd/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 3f2781e7135..1c3b0105b5f 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt index 939e34eb98b..325718e37e1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputDirectory/node/sourceRootRelativePathMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map index 2e84a488006..d7eeef9ca49 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index 1d422734a9f..46af9b6678b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/amd/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map index 2e84a488006..d7eeef9ca49 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt index 1d422734a9f..46af9b6678b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathMultifolderSpecifyOutputFile/node/sourceRootRelativePathMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt index bf10b5ed9fc..181dcd2d8c6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/test.js.map index 1934eb39c28..eb9e3b663f1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt index bf10b5ed9fc..181dcd2d8c6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/sourceRootRelativePathSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/test.js.map index 1934eb39c28..eb9e3b663f1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 1934eb39c28..eb9e3b663f1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt index cd059036df7..3a97d4540e2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/amd/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 1934eb39c28..eb9e3b663f1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt index cd059036df7..3a97d4540e2 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputDirectory/node/sourceRootRelativePathSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map index fb5adc76d59..cc3b3971208 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt index 7e219ee4efd..c85101c0026 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/amd/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map index fb5adc76d59..cc3b3971208 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt index 7e219ee4efd..c85101c0026 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSimpleSpecifyOutputFile/node/sourceRootRelativePathSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt index 75655274f8a..e3643a7e1e4 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/test.js.map index a68bad790ab..7792f8a3df6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt index 75655274f8a..e3643a7e1e4 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/sourceRootRelativePathSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/test.js.map index a68bad790ab..7792f8a3df6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index a68bad790ab..7792f8a3df6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt index 91537c88524..c76e3a2c05c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/amd/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index a68bad790ab..7792f8a3df6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt index 91537c88524..c76e3a2c05c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputDirectory/node/sourceRootRelativePathSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map index 47e290804f2..ef39d6c5cdb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt index 32bf6d56977..c0ad748bf2b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/amd/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map index 47e290804f2..ef39d6c5cdb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt index 32bf6d56977..c0ad748bf2b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourceRootRelativePathSubfolderSpecifyOutputFile/node/sourceRootRelativePathSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/sourcemapMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/sourcemapMixedSubfolderNoOutdir.sourcemap.txt index a5aeda6cdd8..40be0ca660c 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/sourcemapMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/sourcemapMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/test.js.map index 9bac80ea492..c9a79b35d3c 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/sourcemapMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/sourcemapMixedSubfolderNoOutdir.sourcemap.txt index 5355f2e907e..d3eeabc27b5 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/sourcemapMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/sourcemapMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/test.js.map index 9bac80ea492..c9a79b35d3c 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 46ba86b781c..bad31ecf8d2 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 045f82046ce..4557384d5b8 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 46ba86b781c..bad31ecf8d2 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 4424c9c0872..7a377d04299 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:../../test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index d1972c6fac7..a1d591a0497 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index f7faa24855f..b1d3f293b7e 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index d1972c6fac7..a1d591a0497 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt index 9931e5b4418..676e8f264ec 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/node/sourcemapMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index eb72bfc3c02..4f87045fd25 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index b75480da1e7..a73c3b0852a 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index eb72bfc3c02..4f87045fd25 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index 165ca8ce022..77ff10492be 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:../test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/sourcemapMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/sourcemapMultifolderNoOutdir.sourcemap.txt index 3a0747b7391..9f8f5856ae8 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/sourcemapMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/sourcemapMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/test.js.map index c44bc996538..38fe91174ea 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/sourcemapMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/sourcemapMultifolderNoOutdir.sourcemap.txt index 3a0747b7391..9f8f5856ae8 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/sourcemapMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/sourcemapMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/test.js.map index c44bc996538..38fe91174ea 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 39003b7de59..4c7bad4f920 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt index f46ef4b5d46..cb0659450da 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/amd/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 39003b7de59..4c7bad4f920 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt index f46ef4b5d46..cb0659450da 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputDirectory/node/sourcemapMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:../../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:../../../test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/bin/test.js.map index 8df103744b5..37b77beb154 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt index e5f624e893b..fa9ebc580e6 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/amd/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/bin/test.js.map index 8df103744b5..37b77beb154 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../../outputdir_multifolder_ref/m2.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt index e5f624e893b..fa9ebc580e6 100644 --- a/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapMultifolderSpecifyOutputFile/node/sourcemapMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:../test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/sourcemapSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/sourcemapSimpleNoOutdir.sourcemap.txt index 37f3a793697..17bbd902b96 100644 --- a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/sourcemapSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/sourcemapSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/test.js.map index 35110f566c5..69f4d8bbfc1 100644 --- a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/sourcemapSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/sourcemapSimpleNoOutdir.sourcemap.txt index 37f3a793697..17bbd902b96 100644 --- a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/sourcemapSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/sourcemapSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/test.js.map index 35110f566c5..69f4d8bbfc1 100644 --- a/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index dcdfb881785..5ec3a45d1bd 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt index 1d4ac548211..0a6c6e15aa1 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/amd/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index dcdfb881785..5ec3a45d1bd 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt index 1d4ac548211..0a6c6e15aa1 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputDirectory/node/sourcemapSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/bin/test.js.map index f358b98d465..b7b29ed1cf8 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/sourcemapSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/sourcemapSimpleSpecifyOutputFile.sourcemap.txt index bd56afebe59..6343dcc34c6 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/sourcemapSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/amd/sourcemapSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/bin/test.js.map index f358b98d465..b7b29ed1cf8 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.sourcemap.txt index bd56afebe59..6343dcc34c6 100644 --- a/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSimpleSpecifyOutputFile/node/sourcemapSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/sourcemapSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/sourcemapSubfolderNoOutdir.sourcemap.txt index d35b75a2de1..6bdf8e8ef31 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/sourcemapSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/sourcemapSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/test.js.map index a91cc4d9881..ef084bb2128 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/sourcemapSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/sourcemapSubfolderNoOutdir.sourcemap.txt index d35b75a2de1..6bdf8e8ef31 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/sourcemapSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/sourcemapSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/test.js.map index a91cc4d9881..ef084bb2128 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 0024c7c2747..22a81dc63bc 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt index 079673b4779..2de709b09ab 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/amd/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 0024c7c2747..22a81dc63bc 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt index 079673b4779..2de709b09ab 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputDirectory/node/sourcemapSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:../../test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/bin/test.js.map index 6882b70c389..91ea14b3da4 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt index 9f06bde3b12..9ca0493ff41 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/amd/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/bin/test.js.map index 6882b70c389..91ea14b3da4 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt index 9f06bde3b12..9ca0493ff41 100644 --- a/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcemapSubfolderSpecifyOutputFile/node/sourcemapSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:../test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt index ecf6b4f4fb4..6abc36a0832 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt index 65a337f5eab..49e704a99e1 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/sourcerootUrlMixedSubfolderNoOutdir.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 0f0eb1aa02a..7e0989aabb0 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -325,17 +325,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -347,23 +342,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 2a21f422960..e425f41290b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt index 30caf09e890..3d19accc614 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -324,17 +324,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -346,23 +341,26 @@ sourceFile:test.ts 2 >Emitted(2, 34) Source(2, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map index 156e391d669..7a70d18105c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index c2331c962e7..d4cac643490 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map index 156e391d669..7a70d18105c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt index 96a83ac34b2..cb96dcbf7d7 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/node/sourcerootUrlMixedSubfolderSpecifyOutputFile.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map index c5ec380afae..53e31e30260 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index d21b9752018..d54fa316273 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -319,17 +319,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -341,23 +336,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map index c5ec380afae..53e31e30260 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/bin/outAndOutDirFile.js.map @@ -1 +1 @@ -{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt index a4436e03b4d..8bd8c2ac035 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/node/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory.sourcemap.txt @@ -318,17 +318,12 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(3, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^-> +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>/// 1-> @@ -340,23 +335,26 @@ sourceFile:test.ts 2 >Emitted(12, 34) Source(2, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) -2 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) -3 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) -4 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) -5 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(1) +2 >Emitted(13, 5) Source(3, 5) + SourceIndex(1) +3 >Emitted(13, 7) Source(3, 7) + SourceIndex(1) +4 >Emitted(13, 10) Source(3, 10) + SourceIndex(1) +5 >Emitted(13, 12) Source(3, 12) + SourceIndex(1) +6 >Emitted(13, 13) Source(3, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/sourcerootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/sourcerootUrlMultifolderNoOutdir.sourcemap.txt index f5758392a22..a70e80c9c1a 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/sourcerootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/sourcerootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/sourcerootUrlMultifolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/sourcerootUrlMultifolderNoOutdir.sourcemap.txt index f5758392a22..a70e80c9c1a 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/sourcerootUrlMultifolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/sourcerootUrlMultifolderNoOutdir.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 309061b94ed..4f4f068056f 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/amd/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map index 63113a47468..859053b5510 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAEA,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt index 309061b94ed..4f4f068056f 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputDirectory/node/sourcerootUrlMultifolderSpecifyOutputDirectory.sourcemap.txt @@ -296,17 +296,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >/// - >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>/// 1-> @@ -318,23 +313,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(2, 59) Source(2, 59) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) -3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -4 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) -5 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +4 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +5 >Emitted(3, 12) Source(3, 12) + SourceIndex(0) +6 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map index df7254bd000..2e0ee57fe05 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt index 2903da82815..823af8d1bc3 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/amd/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map index df7254bd000..2e0ee57fe05 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACND,AAFA,iCAAiC;AACjC,0DAA0D;IACtD,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_multifolder/ref/m1.ts","outputdir_multifolder_ref/m2.ts","outputdir_multifolder/test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","m2_c1","m2_c1.constructor","m2_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAC;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,0DAA0D;AAC1D,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt index 2903da82815..823af8d1bc3 100644 --- a/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlMultifolderSpecifyOutputFile/node/sourcerootUrlMultifolderSpecifyOutputFile.sourcemap.txt @@ -284,17 +284,12 @@ sourceFile:outputdir_multifolder/test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1->/// - >/// - > -2 > -3 >/// -1->Emitted(21, 1) Source(3, 1) + SourceIndex(2) -2 >Emitted(21, 1) Source(1, 1) + SourceIndex(2) -3 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 >/// +1->Emitted(21, 1) Source(1, 1) + SourceIndex(2) +2 >Emitted(21, 34) Source(1, 34) + SourceIndex(2) --- >>>/// 1-> @@ -306,23 +301,26 @@ sourceFile:outputdir_multifolder/test.ts 2 >Emitted(22, 59) Source(2, 59) + SourceIndex(2) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) -2 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) -3 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) -4 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) -5 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(23, 1) Source(3, 1) + SourceIndex(2) +2 >Emitted(23, 5) Source(3, 5) + SourceIndex(2) +3 >Emitted(23, 7) Source(3, 7) + SourceIndex(2) +4 >Emitted(23, 10) Source(3, 10) + SourceIndex(2) +5 >Emitted(23, 12) Source(3, 12) + SourceIndex(2) +6 >Emitted(23, 13) Source(3, 13) + SourceIndex(2) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/sourcerootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/sourcerootUrlSimpleNoOutdir.sourcemap.txt index 6784e74b54c..e9ff85f6fe6 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/sourcerootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/sourcerootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/sourcerootUrlSimpleNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/sourcerootUrlSimpleNoOutdir.sourcemap.txt index 6784e74b54c..e9ff85f6fe6 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/sourcerootUrlSimpleNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/sourcerootUrlSimpleNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index b6a9d4f8786..411004d82a3 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/amd/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index ec67c8da25b..ad9ad3d5ce0 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt index b6a9d4f8786..411004d82a3 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputDirectory/node/sourcerootUrlSimpleSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map index a107f15c1bf..f1c6e3bd1b7 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt index a4f350382a6..10e2e3700c1 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/amd/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map index a107f15c1bf..f1c6e3bd1b7 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,6BAA6B;IACzB,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,6BAA6B;AAC7B,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt index a4f350382a6..10e2e3700c1 100644 --- a/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSimpleSpecifyOutputFile/node/sourcerootUrlSimpleSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 30) Source(1, 30) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/sourcerootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/sourcerootUrlSubfolderNoOutdir.sourcemap.txt index 333f432766e..c8b19a1227f 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/sourcerootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/sourcerootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/sourcerootUrlSubfolderNoOutdir.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/sourcerootUrlSubfolderNoOutdir.sourcemap.txt index 333f432766e..c8b19a1227f 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/sourcerootUrlSubfolderNoOutdir.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/sourcerootUrlSubfolderNoOutdir.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index 68dc81acc3e..31798101a57 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/amd/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 7a5bbb049d9..014979baf03 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AACA,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":["c1","c1.constructor","f1"],"mappings":"AAAA,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAA;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt index 68dc81acc3e..31798101a57 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputDirectory/node/sourcerootUrlSubfolderSpecifyOutputDirectory.sourcemap.txt @@ -153,34 +153,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 >/// - > -2 > -3 >/// -1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 >/// +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 34) Source(1, 34) + SourceIndex(0) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) -4 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -5 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +4 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map index 6e45ee8da7d..e80a550275c 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 3ca3d1774f8..791b3dbcecb 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/amd/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map index 6e45ee8da7d..e80a550275c 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/bin/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACPD,AADA,iCAAiC;IAC7B,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":["m1_c1","m1_c1.constructor","m1_f1","c1","c1.constructor","f1"],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAAA;IAEAC,CAACA;IAADD,YAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACIE,MAAMA,CAACA,YAAYA,CAACA;AACxBA,CAACA;ACRD,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAAC;IAEAC,CAACA;IAADD,SAACA;AAADA,CAACA,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACIE,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt index 3ca3d1774f8..791b3dbcecb 100644 --- a/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt +++ b/tests/baselines/reference/project/sourcerootUrlSubfolderSpecifyOutputFile/node/sourcerootUrlSubfolderSpecifyOutputFile.sourcemap.txt @@ -147,34 +147,33 @@ sourceFile:test.ts ------------------------------------------------------------------- >>>/// 1-> -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1->/// - > -2 > -3 >/// -1->Emitted(11, 1) Source(2, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(1, 1) + SourceIndex(1) -3 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 >/// +1->Emitted(11, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(1) --- >>>var a1 = 10; -1 >^^^^ -2 > ^^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> 1 > - >var -2 > a1 -3 > = -4 > 10 -5 > ; -1 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) -2 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) -3 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) -4 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) -5 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) +2 >^^^^ +3 > ^^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^-> +1 > + > +2 >var +3 > a1 +4 > = +5 > 10 +6 > ; +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(2, 5) + SourceIndex(1) +3 >Emitted(12, 7) Source(2, 7) + SourceIndex(1) +4 >Emitted(12, 10) Source(2, 10) + SourceIndex(1) +5 >Emitted(12, 12) Source(2, 12) + SourceIndex(1) +6 >Emitted(12, 13) Source(2, 13) + SourceIndex(1) --- >>>var c1 = (function () { 1-> diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index 27e7df62ab1..b12d564d880 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5109, 39), Decl(lib.d.ts, 5116, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5109, 39), Decl(lib.d.ts, 5116, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5046, 22), Decl(lib.d.ts, 5053, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 734906688fd..90ab021de59 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -1,2 +1,2 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","Sample.Thing.Widgets.FindWidget.destroy","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,OAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC;oBAAAC;oBAQAC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExBF,6BAAGA,GAAVA,UAAWA,KAA6BA;wBAEvCG,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBACFH,sBAACA;gBAADA,CAACA,AARDD,IAQCA;gBARYA,oBAAeA,kBAQ3BA,CAAAA;YACFA,CAACA,EAV2BD,IAAIA,GAAJA,YAAIA,KAAJA,YAAIA,QAU/BA;QAADA,CAACA,EAVqBD,KAAKA,GAALA,aAAKA,KAALA,aAAKA,QAU1BA;IAADA,CAACA,EAVaD,OAAOA,GAAPA,cAAOA,KAAPA,cAAOA,QAUpBA;AAADA,CAACA,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,IAAO,MAAM,CAoBZ;AApBD,WAAO,MAAM;IAACA,IAAAA,KAAKA,CAoBlBA;IApBaA,WAAAA,KAAKA;QAACQ,IAAAA,OAAOA,CAoB1BA;QApBmBA,WAAAA,OAAOA,EAACA,CAACA;YAC5BC;gBAKCC,oBAAoBA,SAAkCA;oBAAlCC,cAASA,GAATA,SAASA,CAAyBA;oBAD9CA,YAAOA,GAAOA,IAAIA,CAACA;oBAGvBA,AADAA,aAAaA;oBACbA,SAASA,CAACA,SAASA,CAACA,WAAWA,EAAEA,IAAIA,CAACA,CAACA;gBAC3CA,CAACA;gBANMD,wBAAGA,GAAVA,UAAWA,MAAyCA,IAAIE,EAAEA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAAAA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA;gBAAAA,CAACA,CAAAA,CAACA;gBAQlFF,+BAAUA,GAAjBA;oBACCG,MAAMA,CAACA,OAAOA,CAACA;gBAChBA,CAACA;gBAEMH,4BAAOA,GAAdA;gBAEAI,CAACA;gBAEFJ,iBAACA;YAADA,CAACA,AAlBDD,IAkBCA;YAlBYA,kBAAUA,aAkBtBA,CAAAA;QACFA,CAACA,EApBmBD,OAAOA,GAAPA,aAAOA,KAAPA,aAAOA,QAoB1BA;IAADA,CAACA,EApBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAoBlBA;AAADA,CAACA,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAAe;IAAuFC,CAACA;IAA3CD,sCAAeA,GAAtBA,cAAmCE,MAAMA,CAACA,IAAIA,CAACA,CAAAA,CAACA;IAACF,mBAACA;AAADA,CAACA,AAAxF,IAAwF;AASxF,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAACf,IAAAA,KAAKA,CAwBlBA;IAxBaA,WAAAA,KAAKA;QAACQ,IAAAA,SAASA,CAwB5BA;QAxBmBA,WAAAA,SAASA;YAACU,IAAAA,SAASA,CAwBtCA;YAxB6BA,WAAAA,SAASA,EAACA,CAACA;gBAExCC;oBACOC,eAAoBA,IAAWA;wBAAXC,SAAIA,GAAJA,IAAIA,CAAOA;oBAAIA,CAACA;oBACnCD,qBAAKA,GAAZA;wBACCE,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBAEMF,sBAAMA,GAAbA,UAAcA,KAAYA;wBACzBG,MAAMA,CAACA,IAAIA,KAAKA,KAAKA,CAACA;oBACvBA,CAACA;oBAEMH,uBAAOA,GAAdA,cAA0BI,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBACzCJ,YAACA;gBAADA,CAACA,AAXDD,IAWCA;gBAXYA,eAAKA,QAWjBA,CAAAA;gBAEDA;oBAA0BM,wBAAYA;oBAAtCA;wBAA0BC,8BAAYA;oBAQtCA,CAACA;oBANAD,aAAaA;oBACNA,8BAAeA,GAAtBA;wBACCE,MAAMA,CAACA,IAAIA,KAAKA,CAACA,IAAIA,CAACA,CAACA;oBACxBA,CAACA;oBAGFF,WAACA;gBAADA,CAACA,AARDN,EAA0BA,YAAYA,EAQrCA;gBARYA,cAAIA,OAQhBA,CAAAA;YACFA,CAACA,EAxB6BD,SAASA,GAATA,mBAASA,KAATA,mBAASA,QAwBtCA;QAADA,CAACA,EAxBmBV,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file +{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","Sample.Thing.Widgets.FindWidget.destroy","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,OAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC;oBAAAC;oBAQAC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExBF,6BAAGA,GAAVA,UAAWA,KAA6BA;wBAEvCG,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBACFH,sBAACA;gBAADA,CAACA,AARDD,IAQCA;gBARYA,oBAAeA,kBAQ3BA,CAAAA;YACFA,CAACA,EAV2BD,IAAIA,GAAJA,YAAIA,KAAJA,YAAIA,QAU/BA;QAADA,CAACA,EAVqBD,KAAKA,GAALA,aAAKA,KAALA,aAAKA,QAU1BA;IAADA,CAACA,EAVaD,OAAOA,GAAPA,cAAOA,KAAPA,cAAOA,QAUpBA;AAADA,CAACA,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,IAAO,MAAM,CAoBZ;AApBD,WAAO,MAAM;IAACA,IAAAA,KAAKA,CAoBlBA;IApBaA,WAAAA,KAAKA;QAACQ,IAAAA,OAAOA,CAoB1BA;QApBmBA,WAAAA,OAAOA,EAACA,CAACA;YAC5BC;gBAKCC,oBAAoBA,SAAkCA;oBAAlCC,cAASA,GAATA,SAASA,CAAyBA;oBAD9CA,YAAOA,GAAOA,IAAIA,CAACA;oBAEvBA,aAAaA;oBACbA,SAASA,CAACA,SAASA,CAACA,WAAWA,EAAEA,IAAIA,CAACA,CAACA;gBAC3CA,CAACA;gBANMD,wBAAGA,GAAVA,UAAWA,MAAyCA,IAAIE,EAAEA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAAAA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA;gBAAAA,CAACA,CAAAA,CAACA;gBAQlFF,+BAAUA,GAAjBA;oBACCG,MAAMA,CAACA,OAAOA,CAACA;gBAChBA,CAACA;gBAEMH,4BAAOA,GAAdA;gBAEAI,CAACA;gBAEFJ,iBAACA;YAADA,CAACA,AAlBDD,IAkBCA;YAlBYA,kBAAUA,aAkBtBA,CAAAA;QACFA,CAACA,EApBmBD,OAAOA,GAAPA,aAAOA,KAAPA,aAAOA,QAoB1BA;IAADA,CAACA,EApBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAoBlBA;AAADA,CAACA,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAAe;IAAuFC,CAACA;IAA3CD,sCAAeA,GAAtBA,cAAmCE,MAAMA,CAACA,IAAIA,CAACA,CAAAA,CAACA;IAACF,mBAACA;AAADA,CAACA,AAAxF,IAAwF;AASxF,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAACf,IAAAA,KAAKA,CAwBlBA;IAxBaA,WAAAA,KAAKA;QAACQ,IAAAA,SAASA,CAwB5BA;QAxBmBA,WAAAA,SAASA;YAACU,IAAAA,SAASA,CAwBtCA;YAxB6BA,WAAAA,SAASA,EAACA,CAACA;gBAExCC;oBACOC,eAAoBA,IAAWA;wBAAXC,SAAIA,GAAJA,IAAIA,CAAOA;oBAAIA,CAACA;oBACnCD,qBAAKA,GAAZA;wBACCE,MAAMA,CAACA,IAAIA,CAACA;oBACbA,CAACA;oBAEMF,sBAAMA,GAAbA,UAAcA,KAAYA;wBACzBG,MAAMA,CAACA,IAAIA,KAAKA,KAAKA,CAACA;oBACvBA,CAACA;oBAEMH,uBAAOA,GAAdA,cAA0BI,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBACzCJ,YAACA;gBAADA,CAACA,AAXDD,IAWCA;gBAXYA,eAAKA,QAWjBA,CAAAA;gBAEDA;oBAA0BM,wBAAYA;oBAAtCA;wBAA0BC,8BAAYA;oBAQtCA,CAACA;oBANAD,aAAaA;oBACNA,8BAAeA,GAAtBA;wBACCE,MAAMA,CAACA,IAAIA,KAAKA,CAACA,IAAIA,CAACA,CAACA;oBACxBA,CAACA;oBAGFF,WAACA;gBAADA,CAACA,AARDN,EAA0BA,YAAYA,EAQrCA;gBARYA,cAAIA,OAQhBA,CAAAA;YACFA,CAACA,EAxB6BD,SAASA,GAATA,mBAASA,KAATA,mBAASA,QAwBtCA;QAADA,CAACA,EAxBmBV,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 8f45e0ea715..3b693f7c282 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -737,18 +737,14 @@ sourceFile:recursiveClassReferenceTest.ts --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > constructor(private codeThing: Sample.Thing.ICodeThing) { - > // scenario 1 > -2 > -3 > // scenario 1 -1 >Emitted(40, 21) Source(52, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -2 >Emitted(40, 21) Source(51, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) -3 >Emitted(40, 34) Source(51, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 > // scenario 1 +1 >Emitted(40, 21) Source(51, 7) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) +2 >Emitted(40, 34) Source(51, 20) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.constructor) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/recursiveTupleTypes1.js b/tests/baselines/reference/recursiveTupleTypes1.js new file mode 100644 index 00000000000..f4fa8ef4816 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes1.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes1.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes1.symbols b/tests/baselines/reference/recursiveTupleTypes1.symbols new file mode 100644 index 00000000000..8bd0797f3f6 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + + children: [Tree2, Tree1]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes1.types b/tests/baselines/reference/recursiveTupleTypes1.types new file mode 100644 index 00000000000..9dfdc768ddb --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree1]; +>children : [Tree2, Tree1] +>Tree2 : Tree2 +>Tree1 : Tree1 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/recursiveTupleTypes2.js b/tests/baselines/reference/recursiveTupleTypes2.js new file mode 100644 index 00000000000..60dde8ef4d5 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes2.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes2.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes2.symbols b/tests/baselines/reference/recursiveTupleTypes2.symbols new file mode 100644 index 00000000000..2895f1b5669 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + + children: [Tree2, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes2.types b/tests/baselines/reference/recursiveTupleTypes2.types new file mode 100644 index 00000000000..9ce8e5daf79 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree2]; +>children : [Tree2, Tree2] +>Tree2 : Tree2 +>Tree2 : Tree2 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/reexportClassDefinition.js b/tests/baselines/reference/reexportClassDefinition.js new file mode 100644 index 00000000000..5d534f1e3a3 --- /dev/null +++ b/tests/baselines/reference/reexportClassDefinition.js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/externalModules/reexportClassDefinition.ts] //// + +//// [foo1.ts] +class x{} +export = x; + +//// [foo2.ts] +import foo1 = require('./foo1'); + +export = { + x: foo1 +} + +//// [foo3.ts] +import foo2 = require('./foo2') +class x extends foo2.x {} + + + +//// [foo1.js] +var x = (function () { + function x() { + } + return x; +})(); +module.exports = x; +//// [foo2.js] +var foo1 = require('./foo1'); +module.exports = { + x: foo1 +}; +//// [foo3.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo2 = require('./foo2'); +var x = (function (_super) { + __extends(x, _super); + function x() { + _super.apply(this, arguments); + } + return x; +})(foo2.x); diff --git a/tests/baselines/reference/reexportClassDefinition.symbols b/tests/baselines/reference/reexportClassDefinition.symbols new file mode 100644 index 00000000000..52133657985 --- /dev/null +++ b/tests/baselines/reference/reexportClassDefinition.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/externalModules/foo3.ts === +import foo2 = require('./foo2') +>foo2 : Symbol(foo2, Decl(foo3.ts, 0, 0)) + +class x extends foo2.x {} +>x : Symbol(x, Decl(foo3.ts, 0, 31)) +>foo2 : Symbol(foo2, Decl(foo3.ts, 0, 0)) + + +=== tests/cases/conformance/externalModules/foo1.ts === +class x{} +>x : Symbol(x, Decl(foo1.ts, 0, 0)) + +export = x; +>x : Symbol(x, Decl(foo1.ts, 0, 0)) + +=== tests/cases/conformance/externalModules/foo2.ts === +import foo1 = require('./foo1'); +>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0)) + +export = { + x: foo1 +>x : Symbol(x, Decl(foo2.ts, 2, 10)) +>foo1 : Symbol(foo1, Decl(foo2.ts, 0, 0)) +} + diff --git a/tests/baselines/reference/reexportClassDefinition.types b/tests/baselines/reference/reexportClassDefinition.types new file mode 100644 index 00000000000..c39bbf9c136 --- /dev/null +++ b/tests/baselines/reference/reexportClassDefinition.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/externalModules/foo3.ts === +import foo2 = require('./foo2') +>foo2 : { x: typeof x; } + +class x extends foo2.x {} +>x : x +>foo2.x : x +>foo2 : { x: typeof x; } +>x : typeof x + + +=== tests/cases/conformance/externalModules/foo1.ts === +class x{} +>x : x + +export = x; +>x : x + +=== tests/cases/conformance/externalModules/foo2.ts === +import foo1 = require('./foo1'); +>foo1 : typeof foo1 + +export = { +>{ x: foo1} : { x: typeof foo1; } + + x: foo1 +>x : typeof foo1 +>foo1 : typeof foo1 +} + diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.symbols b/tests/baselines/reference/regExpWithSlashInCharClass.symbols index 2131f471466..68a257a9666 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.symbols +++ b/tests/baselines/reference/regExpWithSlashInCharClass.symbols @@ -1,16 +1,16 @@ === tests/cases/compiler/regExpWithSlashInCharClass.ts === var foo1 = "a/".replace(/.[/]/, ""); >foo1 : Symbol(foo1, Decl(regExpWithSlashInCharClass.ts, 0, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : Symbol(foo2, Decl(regExpWithSlashInCharClass.ts, 1, 3)) ->"a//".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a//".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : Symbol(foo3, Decl(regExpWithSlashInCharClass.ts, 2, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.types b/tests/baselines/reference/regExpWithSlashInCharClass.types index 40eed3c109c..fafe6e1be69 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.types +++ b/tests/baselines/reference/regExpWithSlashInCharClass.types @@ -2,27 +2,27 @@ var foo1 = "a/".replace(/.[/]/, ""); >foo1 : string >"a/".replace(/.[/]/, "") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/]/ : RegExp >"" : string var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : string >"a//".replace(/.[//]/g, "") : string ->"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a//" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[//]/g : RegExp >"" : string var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : string >"a/".replace(/.[/no sleep /till/]/, "bugfix") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/no sleep /till/]/ : RegExp >"bugfix" : string diff --git a/tests/baselines/reference/requiredInitializedParameter1.errors.txt b/tests/baselines/reference/requiredInitializedParameter1.errors.txt new file mode 100644 index 00000000000..ef958dbdec9 --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter1.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/requiredInitializedParameter1.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/requiredInitializedParameter1.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/requiredInitializedParameter1.ts (2 errors) ==== + function f1(a, b = 0, c) { } + function f2(a, b = 0, c = 0) { } + function f3(a, b = 0, c?) { } + function f4(a, b = 0, ...c) { } + + f1(0, 1, 2); + f2(0, 1, 2); + f3(0, 1, 2); + f4(0, 1, 2); + + f1(0, 1); + ~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f2(0, 1); + f3(0, 1); + f4(0, 1); + + f1(0); + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f2(0); + f3(0); + f4(0); \ No newline at end of file diff --git a/tests/baselines/reference/requiredInitializedParameter1.js b/tests/baselines/reference/requiredInitializedParameter1.js new file mode 100644 index 00000000000..0fe07503056 --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter1.js @@ -0,0 +1,51 @@ +//// [requiredInitializedParameter1.ts] +function f1(a, b = 0, c) { } +function f2(a, b = 0, c = 0) { } +function f3(a, b = 0, c?) { } +function f4(a, b = 0, ...c) { } + +f1(0, 1, 2); +f2(0, 1, 2); +f3(0, 1, 2); +f4(0, 1, 2); + +f1(0, 1); +f2(0, 1); +f3(0, 1); +f4(0, 1); + +f1(0); +f2(0); +f3(0); +f4(0); + +//// [requiredInitializedParameter1.js] +function f1(a, b, c) { + if (b === void 0) { b = 0; } +} +function f2(a, b, c) { + if (b === void 0) { b = 0; } + if (c === void 0) { c = 0; } +} +function f3(a, b, c) { + if (b === void 0) { b = 0; } +} +function f4(a, b) { + if (b === void 0) { b = 0; } + var c = []; + for (var _i = 2; _i < arguments.length; _i++) { + c[_i - 2] = arguments[_i]; + } +} +f1(0, 1, 2); +f2(0, 1, 2); +f3(0, 1, 2); +f4(0, 1, 2); +f1(0, 1); +f2(0, 1); +f3(0, 1); +f4(0, 1); +f1(0); +f2(0); +f3(0); +f4(0); diff --git a/tests/baselines/reference/requiredInitializedParameter2.errors.txt b/tests/baselines/reference/requiredInitializedParameter2.errors.txt new file mode 100644 index 00000000000..5dcec536e1b --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter2.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/requiredInitializedParameter2.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'I1'. + Types of property 'method' are incompatible. + Type '(a: number, b: any) => void' is not assignable to type '() => any'. + + +==== tests/cases/compiler/requiredInitializedParameter2.ts (1 errors) ==== + interface I1 { + method(); + } + + class C1 implements I1 { + ~~ +!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'. +!!! error TS2420: Types of property 'method' are incompatible. +!!! error TS2420: Type '(a: number, b: any) => void' is not assignable to type '() => any'. + method(a = 0, b) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/requiredInitializedParameter2.js b/tests/baselines/reference/requiredInitializedParameter2.js new file mode 100644 index 00000000000..3c69d54e1d9 --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter2.js @@ -0,0 +1,18 @@ +//// [requiredInitializedParameter2.ts] +interface I1 { + method(); +} + +class C1 implements I1 { + method(a = 0, b) { } +} + +//// [requiredInitializedParameter2.js] +var C1 = (function () { + function C1() { + } + C1.prototype.method = function (a, b) { + if (a === void 0) { a = 0; } + }; + return C1; +})(); diff --git a/tests/baselines/reference/requiredInitializedParameter3.js b/tests/baselines/reference/requiredInitializedParameter3.js new file mode 100644 index 00000000000..68e1aa696ea --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter3.js @@ -0,0 +1,27 @@ +//// [requiredInitializedParameter3.ts] +interface I1 { + method(); +} + +class C1 implements I1 { + method(a = 0, b?) { } +} + +//// [requiredInitializedParameter3.js] +var C1 = (function () { + function C1() { + } + C1.prototype.method = function (a, b) { + if (a === void 0) { a = 0; } + }; + return C1; +})(); + + +//// [requiredInitializedParameter3.d.ts] +interface I1 { + method(): any; +} +declare class C1 implements I1 { + method(a?: number, b?: any): void; +} diff --git a/tests/baselines/reference/requiredInitializedParameter3.symbols b/tests/baselines/reference/requiredInitializedParameter3.symbols new file mode 100644 index 00000000000..e9f35b21bcf --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter3.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/requiredInitializedParameter3.ts === +interface I1 { +>I1 : Symbol(I1, Decl(requiredInitializedParameter3.ts, 0, 0)) + + method(); +>method : Symbol(method, Decl(requiredInitializedParameter3.ts, 0, 14)) +} + +class C1 implements I1 { +>C1 : Symbol(C1, Decl(requiredInitializedParameter3.ts, 2, 1)) +>I1 : Symbol(I1, Decl(requiredInitializedParameter3.ts, 0, 0)) + + method(a = 0, b?) { } +>method : Symbol(method, Decl(requiredInitializedParameter3.ts, 4, 24)) +>a : Symbol(a, Decl(requiredInitializedParameter3.ts, 5, 11)) +>b : Symbol(b, Decl(requiredInitializedParameter3.ts, 5, 17)) +} diff --git a/tests/baselines/reference/requiredInitializedParameter3.types b/tests/baselines/reference/requiredInitializedParameter3.types new file mode 100644 index 00000000000..aa37f5e13dd --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter3.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/requiredInitializedParameter3.ts === +interface I1 { +>I1 : I1 + + method(); +>method : () => any +} + +class C1 implements I1 { +>C1 : C1 +>I1 : I1 + + method(a = 0, b?) { } +>method : (a?: number, b?: any) => void +>a : number +>0 : number +>b : any +} diff --git a/tests/baselines/reference/requiredInitializedParameter4.js b/tests/baselines/reference/requiredInitializedParameter4.js new file mode 100644 index 00000000000..3b23f119391 --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter4.js @@ -0,0 +1,20 @@ +//// [requiredInitializedParameter4.ts] +class C1 { + method(a = 0, b) { } +} + +//// [requiredInitializedParameter4.js] +var C1 = (function () { + function C1() { + } + C1.prototype.method = function (a, b) { + if (a === void 0) { a = 0; } + }; + return C1; +})(); + + +//// [requiredInitializedParameter4.d.ts] +declare class C1 { + method(a: number, b: any): void; +} diff --git a/tests/baselines/reference/requiredInitializedParameter4.symbols b/tests/baselines/reference/requiredInitializedParameter4.symbols new file mode 100644 index 00000000000..2790b33698c --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter4.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/requiredInitializedParameter4.ts === +class C1 { +>C1 : Symbol(C1, Decl(requiredInitializedParameter4.ts, 0, 0)) + + method(a = 0, b) { } +>method : Symbol(method, Decl(requiredInitializedParameter4.ts, 0, 10)) +>a : Symbol(a, Decl(requiredInitializedParameter4.ts, 1, 11)) +>b : Symbol(b, Decl(requiredInitializedParameter4.ts, 1, 17)) +} diff --git a/tests/baselines/reference/requiredInitializedParameter4.types b/tests/baselines/reference/requiredInitializedParameter4.types new file mode 100644 index 00000000000..c483146a1ba --- /dev/null +++ b/tests/baselines/reference/requiredInitializedParameter4.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/requiredInitializedParameter4.ts === +class C1 { +>C1 : C1 + + method(a = 0, b) { } +>method : (a: number, b: any) => void +>a : number +>0 : number +>b : any +} diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.js b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.js new file mode 100644 index 00000000000..9349da082e8 --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.js @@ -0,0 +1,7 @@ +//// [resolveInterfaceNameWithSameLetDeclarationName1.ts] +interface bar { } +let bar: bar; + + +//// [resolveInterfaceNameWithSameLetDeclarationName1.js] +var bar; diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.symbols b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.symbols new file mode 100644 index 00000000000..bcabaef55ce --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts === +interface bar { } +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3)) + +let bar: bar; +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3)) +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3)) + diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.types b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.types new file mode 100644 index 00000000000..29de2a9f5b4 --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName1.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts === +interface bar { } +>bar : bar + +let bar: bar; +>bar : bar +>bar : bar + diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.js b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.js new file mode 100644 index 00000000000..8f43889191a --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.js @@ -0,0 +1,9 @@ +//// [resolveInterfaceNameWithSameLetDeclarationName2.ts] +interface foo { } +interface bar { } +let bar: bar | foo; +let foo: bar | foo; + +//// [resolveInterfaceNameWithSameLetDeclarationName2.js] +var bar; +var foo; diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.symbols b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.symbols new file mode 100644 index 00000000000..785a464839f --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts === +interface foo { } +>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3)) + +interface bar { } +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3)) + +let bar: bar | foo; +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3)) +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3)) +>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3)) + +let foo: bar | foo; +>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3)) +>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3)) +>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3)) + diff --git a/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.types b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.types new file mode 100644 index 00000000000..6c52661ef49 --- /dev/null +++ b/tests/baselines/reference/resolveInterfaceNameWithSameLetDeclarationName2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts === +interface foo { } +>foo : foo + +interface bar { } +>bar : bar + +let bar: bar | foo; +>bar : bar | foo +>bar : bar +>foo : foo + +let foo: bar | foo; +>foo : bar | foo +>bar : bar +>foo : foo + diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.js b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.js new file mode 100644 index 00000000000..b3dc4f12519 --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.js @@ -0,0 +1,12 @@ +//// [resolveModuleNameWithSameLetDeclarationName1.ts] +declare module foo { + + interface Bar { + + } +} + +let foo: foo.Bar; + +//// [resolveModuleNameWithSameLetDeclarationName1.js] +var foo; diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.symbols b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.symbols new file mode 100644 index 00000000000..21ff88ac388 --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts === +declare module foo { +>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3)) + + interface Bar { +>Bar : Symbol(Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20)) + + } +} + +let foo: foo.Bar; +>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3)) +>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3)) +>Bar : Symbol(foo.Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20)) + diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.types b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.types new file mode 100644 index 00000000000..c278f460201 --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName1.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts === +declare module foo { +>foo : Bar + + interface Bar { +>Bar : Bar + + } +} + +let foo: foo.Bar; +>foo : foo.Bar +>foo : any +>Bar : foo.Bar + diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.js b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.js new file mode 100644 index 00000000000..46b5f58788a --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.js @@ -0,0 +1,11 @@ +//// [resolveModuleNameWithSameLetDeclarationName2.ts] +declare module "punycode" { + interface ucs2 { + decode(string: string): string; + encode(codePoints: number[]): string; + } + + export let ucs2: ucs2; +} + +//// [resolveModuleNameWithSameLetDeclarationName2.js] diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.symbols b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.symbols new file mode 100644 index 00000000000..e98437abb9a --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts === +declare module "punycode" { + interface ucs2 { +>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14)) + + decode(string: string): string; +>decode : Symbol(decode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 1, 20)) +>string : Symbol(string, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 15)) + + encode(codePoints: number[]): string; +>encode : Symbol(encode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 39)) +>codePoints : Symbol(codePoints, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 3, 15)) + } + + export let ucs2: ucs2; +>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14)) +>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14)) +} diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types new file mode 100644 index 00000000000..835e4656f5f --- /dev/null +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts === +declare module "punycode" { + interface ucs2 { +>ucs2 : ucs2 + + decode(string: string): string; +>decode : (string: string) => string +>string : string + + encode(codePoints: number[]): string; +>encode : (codePoints: number[]) => string +>codePoints : number[] + } + + export let ucs2: ucs2; +>ucs2 : ucs2 +>ucs2 : ucs2 +} diff --git a/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.js b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.js new file mode 100644 index 00000000000..ac73145ee50 --- /dev/null +++ b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.js @@ -0,0 +1,13 @@ +//// [resolveTypeAliasWithSameLetDeclarationName1.ts] +class C { } +type baz = C; +let baz: baz; + + +//// [resolveTypeAliasWithSameLetDeclarationName1.js] +var C = (function () { + function C() { + } + return C; +})(); +var baz; diff --git a/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.symbols b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.symbols new file mode 100644 index 00000000000..cd5c05301c0 --- /dev/null +++ b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts === +class C { } +>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0)) + +type baz = C; +>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3)) +>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0)) + +let baz: baz; +>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3)) +>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3)) + diff --git a/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.types b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.types new file mode 100644 index 00000000000..7bb61e29a20 --- /dev/null +++ b/tests/baselines/reference/resolveTypeAliasWithSameLetDeclarationName1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts === +class C { } +>C : C + +type baz = C; +>baz : C +>C : C + +let baz: baz; +>baz : C +>baz : C + diff --git a/tests/baselines/reference/shebang.js b/tests/baselines/reference/shebang.js new file mode 100644 index 00000000000..d7e3a4d8351 --- /dev/null +++ b/tests/baselines/reference/shebang.js @@ -0,0 +1,8 @@ +//// [shebang.ts] +#!/usr/bin/env node +var foo = 'I wish the generated JS to be executed in node'; + + +//// [shebang.js] +#!/usr/bin/env node +var foo = 'I wish the generated JS to be executed in node'; diff --git a/tests/baselines/reference/shebang.symbols b/tests/baselines/reference/shebang.symbols new file mode 100644 index 00000000000..37ad5436674 --- /dev/null +++ b/tests/baselines/reference/shebang.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/shebang.ts === +#!/usr/bin/env node +var foo = 'I wish the generated JS to be executed in node'; +>foo : Symbol(foo, Decl(shebang.ts, 1, 3)) + diff --git a/tests/baselines/reference/shebang.types b/tests/baselines/reference/shebang.types new file mode 100644 index 00000000000..5fd6f0533ec --- /dev/null +++ b/tests/baselines/reference/shebang.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/shebang.ts === +#!/usr/bin/env node +var foo = 'I wish the generated JS to be executed in node'; +>foo : string +>'I wish the generated JS to be executed in node' : string + diff --git a/tests/baselines/reference/shebangError.errors.txt b/tests/baselines/reference/shebangError.errors.txt new file mode 100644 index 00000000000..e8197d8bc5f --- /dev/null +++ b/tests/baselines/reference/shebangError.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/shebangError.ts(2,1): error TS1127: Invalid character. +tests/cases/compiler/shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/shebangError.ts(2,12): error TS2304: Cannot find name 'env'. +tests/cases/compiler/shebangError.ts(2,16): error TS1005: ';' expected. +tests/cases/compiler/shebangError.ts(2,16): error TS2304: Cannot find name 'node'. + + +==== tests/cases/compiler/shebangError.ts (5 errors) ==== + var foo = 'Shebang is only allowed on the first line'; + #!/usr/bin/env node + +!!! error TS1127: Invalid character. + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~ +!!! error TS2304: Cannot find name 'env'. + ~~~~ +!!! error TS1005: ';' expected. + ~~~~ +!!! error TS2304: Cannot find name 'node'. \ No newline at end of file diff --git a/tests/baselines/reference/shebangError.js b/tests/baselines/reference/shebangError.js new file mode 100644 index 00000000000..a8fb376d8a9 --- /dev/null +++ b/tests/baselines/reference/shebangError.js @@ -0,0 +1,8 @@ +//// [shebangError.ts] +var foo = 'Shebang is only allowed on the first line'; +#!/usr/bin/env node + +//// [shebangError.js] +var foo = 'Shebang is only allowed on the first line'; +!/usr/bin / env; +node; diff --git a/tests/baselines/reference/sourceMap-Comments.js b/tests/baselines/reference/sourceMap-Comments.js new file mode 100644 index 00000000000..12a4e5010dd --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments.js @@ -0,0 +1,50 @@ +//// [sourceMap-Comments.ts] +module sas.tools { + export class Test { + public doX(): void { + let f: number = 2; + switch (f) { + case 1: + break; + case 2: + //line comment 1 + //line comment 2 + break; + case 3: + //a comment + break; + } + } + } + +} + + +//// [sourceMap-Comments.js] +var sas; +(function (sas) { + var tools; + (function (tools) { + var Test = (function () { + function Test() { + } + Test.prototype.doX = function () { + var f = 2; + switch (f) { + case 1: + break; + case 2: + //line comment 1 + //line comment 2 + break; + case 3: + //a comment + break; + } + }; + return Test; + })(); + tools.Test = Test; + })(tools = sas.tools || (sas.tools = {})); +})(sas || (sas = {})); +//# sourceMappingURL=sourceMap-Comments.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments.js.map b/tests/baselines/reference/sourceMap-Comments.js.map new file mode 100644 index 00000000000..6e5e0dca071 --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments.js.map @@ -0,0 +1,2 @@ +//// [sourceMap-Comments.js.map] +{"version":3,"file":"sourceMap-Comments.js","sourceRoot":"","sources":["sourceMap-Comments.ts"],"names":["sas","sas.tools","sas.tools.Test","sas.tools.Test.constructor","sas.tools.Test.doX"],"mappings":"AAAA,IAAO,GAAG,CAkBT;AAlBD,WAAO,GAAG;IAACA,IAAAA,KAAKA,CAkBfA;IAlBUA,WAAAA,KAAKA,EAACA,CAACA;QACdC;YAAAC;YAeAC,CAACA;YAdUD,kBAAGA,GAAVA;gBACIE,IAAIA,CAACA,GAAWA,CAACA,CAACA;gBAClBA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;oBACRA,KAAKA,CAACA;wBACFA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBACFA,gBAAgBA;wBAChBA,gBAAgBA;wBAChBA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBACFA,WAAWA;wBACXA,KAAKA,CAACA;gBACdA,CAACA;YACLA,CAACA;YACLF,WAACA;QAADA,CAACA,AAfDD,IAeCA;QAfYA,UAAIA,OAehBA,CAAAA;IAELA,CAACA,EAlBUD,KAAKA,GAALA,SAAKA,KAALA,SAAKA,QAkBfA;AAADA,CAACA,EAlBM,GAAG,KAAH,GAAG,QAkBT"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments.sourcemap.txt b/tests/baselines/reference/sourceMap-Comments.sourcemap.txt new file mode 100644 index 00000000000..fe0b9276994 --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments.sourcemap.txt @@ -0,0 +1,486 @@ +=================================================================== +JsFile: sourceMap-Comments.js +mapUrl: sourceMap-Comments.js.map +sourceRoot: +sources: sourceMap-Comments.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMap-Comments.js +sourceFile:sourceMap-Comments.ts +------------------------------------------------------------------- +>>>var sas; +1 > +2 >^^^^ +3 > ^^^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > +2 >module +3 > sas +4 > .tools { + > export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } + > + > } +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(1, 8) + SourceIndex(0) +3 >Emitted(1, 8) Source(1, 11) + SourceIndex(0) +4 >Emitted(1, 9) Source(19, 2) + SourceIndex(0) +--- +>>>(function (sas) { +1-> +2 >^^^^^^^^^^^ +3 > ^^^ +4 > ^-> +1-> +2 >module +3 > sas +1->Emitted(2, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(2, 12) Source(1, 8) + SourceIndex(0) +3 >Emitted(2, 15) Source(1, 11) + SourceIndex(0) +--- +>>> var tools; +1->^^^^ +2 > ^^^^ +3 > ^^^^^ +4 > ^ +5 > ^^^^^^^^^^-> +1->. +2 > +3 > tools +4 > { + > export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } + > + > } +1->Emitted(3, 5) Source(1, 12) + SourceIndex(0) name (sas) +2 >Emitted(3, 9) Source(1, 12) + SourceIndex(0) name (sas) +3 >Emitted(3, 14) Source(1, 17) + SourceIndex(0) name (sas) +4 >Emitted(3, 15) Source(19, 2) + SourceIndex(0) name (sas) +--- +>>> (function (tools) { +1->^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^-> +1-> +2 > +3 > tools +4 > +5 > { +1->Emitted(4, 5) Source(1, 12) + SourceIndex(0) name (sas) +2 >Emitted(4, 16) Source(1, 12) + SourceIndex(0) name (sas) +3 >Emitted(4, 21) Source(1, 17) + SourceIndex(0) name (sas) +4 >Emitted(4, 23) Source(1, 18) + SourceIndex(0) name (sas) +5 >Emitted(4, 24) Source(1, 19) + SourceIndex(0) name (sas) +--- +>>> var Test = (function () { +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(5, 9) Source(2, 5) + SourceIndex(0) name (sas.tools) +--- +>>> function Test() { +1->^^^^^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(6, 13) Source(2, 5) + SourceIndex(0) name (sas.tools.Test) +--- +>>> } +1->^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > +2 > } +1->Emitted(7, 13) Source(17, 5) + SourceIndex(0) name (sas.tools.Test.constructor) +2 >Emitted(7, 14) Source(17, 6) + SourceIndex(0) name (sas.tools.Test.constructor) +--- +>>> Test.prototype.doX = function () { +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^ +1-> +2 > doX +3 > +1->Emitted(8, 13) Source(3, 16) + SourceIndex(0) name (sas.tools.Test) +2 >Emitted(8, 31) Source(3, 19) + SourceIndex(0) name (sas.tools.Test) +3 >Emitted(8, 34) Source(3, 9) + SourceIndex(0) name (sas.tools.Test) +--- +>>> var f = 2; +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^-> +1 >public doX(): void { + > +2 > let +3 > f +4 > : number = +5 > 2 +6 > ; +1 >Emitted(9, 17) Source(4, 13) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(9, 21) Source(4, 17) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(9, 22) Source(4, 18) + SourceIndex(0) name (sas.tools.Test.doX) +4 >Emitted(9, 25) Source(4, 29) + SourceIndex(0) name (sas.tools.Test.doX) +5 >Emitted(9, 26) Source(4, 30) + SourceIndex(0) name (sas.tools.Test.doX) +6 >Emitted(9, 27) Source(4, 31) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> switch (f) { +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +1-> + > +2 > switch +3 > +4 > ( +5 > f +6 > ) +7 > +8 > { +1->Emitted(10, 17) Source(5, 13) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(10, 23) Source(5, 19) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(10, 24) Source(5, 20) + SourceIndex(0) name (sas.tools.Test.doX) +4 >Emitted(10, 25) Source(5, 21) + SourceIndex(0) name (sas.tools.Test.doX) +5 >Emitted(10, 26) Source(5, 22) + SourceIndex(0) name (sas.tools.Test.doX) +6 >Emitted(10, 27) Source(5, 23) + SourceIndex(0) name (sas.tools.Test.doX) +7 >Emitted(10, 28) Source(5, 24) + SourceIndex(0) name (sas.tools.Test.doX) +8 >Emitted(10, 29) Source(5, 25) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> case 1: +1 >^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +4 > ^^^^^-> +1 > + > +2 > case +3 > 1 +1 >Emitted(11, 21) Source(6, 17) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(11, 26) Source(6, 22) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(11, 27) Source(6, 23) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> break; +1->^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +1->: + > +2 > break +3 > ; +1->Emitted(12, 25) Source(7, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(12, 30) Source(7, 26) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(12, 31) Source(7, 27) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> case 2: +1 >^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^-> +1 > + > +2 > case +3 > 2 +1 >Emitted(13, 21) Source(8, 17) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(13, 26) Source(8, 22) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(13, 27) Source(8, 23) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> //line comment 1 +1->^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^ +3 > ^-> +1->: + > +2 > //line comment 1 +1->Emitted(14, 25) Source(9, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(14, 41) Source(9, 37) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> //line comment 2 +1->^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^ +1-> + > +2 > //line comment 2 +1->Emitted(15, 25) Source(10, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(15, 41) Source(10, 37) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> break; +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +1 > + > +2 > break +3 > ; +1 >Emitted(16, 25) Source(11, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(16, 30) Source(11, 26) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(16, 31) Source(11, 27) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> case 3: +1 >^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +4 > ^^^^^^^^^^-> +1 > + > +2 > case +3 > 3 +1 >Emitted(17, 21) Source(12, 17) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(17, 26) Source(12, 22) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(17, 27) Source(12, 23) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> //a comment +1->^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^ +1->: + > +2 > //a comment +1->Emitted(18, 25) Source(13, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(18, 36) Source(13, 32) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> break; +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ +1 > + > +2 > break +3 > ; +1 >Emitted(19, 25) Source(14, 21) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(19, 30) Source(14, 26) + SourceIndex(0) name (sas.tools.Test.doX) +3 >Emitted(19, 31) Source(14, 27) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> } +1 >^^^^^^^^^^^^^^^^ +2 > ^ +1 > + > +2 > } +1 >Emitted(20, 17) Source(15, 13) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(20, 18) Source(15, 14) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> }; +1 >^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(21, 13) Source(16, 9) + SourceIndex(0) name (sas.tools.Test.doX) +2 >Emitted(21, 14) Source(16, 10) + SourceIndex(0) name (sas.tools.Test.doX) +--- +>>> return Test; +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^^ +1-> + > +2 > } +1->Emitted(22, 13) Source(17, 5) + SourceIndex(0) name (sas.tools.Test) +2 >Emitted(22, 24) Source(17, 6) + SourceIndex(0) name (sas.tools.Test) +--- +>>> })(); +1 >^^^^^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } +1 >Emitted(23, 9) Source(17, 5) + SourceIndex(0) name (sas.tools.Test) +2 >Emitted(23, 10) Source(17, 6) + SourceIndex(0) name (sas.tools.Test) +3 >Emitted(23, 10) Source(2, 5) + SourceIndex(0) name (sas.tools) +4 >Emitted(23, 14) Source(17, 6) + SourceIndex(0) name (sas.tools) +--- +>>> tools.Test = Test; +1->^^^^^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^-> +1-> +2 > Test +3 > { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } +4 > +1->Emitted(24, 9) Source(2, 18) + SourceIndex(0) name (sas.tools) +2 >Emitted(24, 19) Source(2, 22) + SourceIndex(0) name (sas.tools) +3 >Emitted(24, 26) Source(17, 6) + SourceIndex(0) name (sas.tools) +4 >Emitted(24, 27) Source(17, 6) + SourceIndex(0) name (sas.tools) +--- +>>> })(tools = sas.tools || (sas.tools = {})); +1->^^^^ +2 > ^ +3 > ^^ +4 > ^^^^^ +5 > ^^^ +6 > ^^^^^^^^^ +7 > ^^^^^ +8 > ^^^^^^^^^ +9 > ^^^^^^^^ +1-> + > + > +2 > } +3 > +4 > tools +5 > +6 > tools +7 > +8 > tools +9 > { + > export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } + > + > } +1->Emitted(25, 5) Source(19, 1) + SourceIndex(0) name (sas.tools) +2 >Emitted(25, 6) Source(19, 2) + SourceIndex(0) name (sas.tools) +3 >Emitted(25, 8) Source(1, 12) + SourceIndex(0) name (sas) +4 >Emitted(25, 13) Source(1, 17) + SourceIndex(0) name (sas) +5 >Emitted(25, 16) Source(1, 12) + SourceIndex(0) name (sas) +6 >Emitted(25, 25) Source(1, 17) + SourceIndex(0) name (sas) +7 >Emitted(25, 30) Source(1, 12) + SourceIndex(0) name (sas) +8 >Emitted(25, 39) Source(1, 17) + SourceIndex(0) name (sas) +9 >Emitted(25, 47) Source(19, 2) + SourceIndex(0) name (sas) +--- +>>>})(sas || (sas = {})); +1 > +2 >^ +3 > ^^ +4 > ^^^ +5 > ^^^^^ +6 > ^^^ +7 > ^^^^^^^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > sas +5 > +6 > sas +7 > .tools { + > export class Test { + > public doX(): void { + > let f: number = 2; + > switch (f) { + > case 1: + > break; + > case 2: + > //line comment 1 + > //line comment 2 + > break; + > case 3: + > //a comment + > break; + > } + > } + > } + > + > } +1 >Emitted(26, 1) Source(19, 1) + SourceIndex(0) name (sas) +2 >Emitted(26, 2) Source(19, 2) + SourceIndex(0) name (sas) +3 >Emitted(26, 4) Source(1, 8) + SourceIndex(0) +4 >Emitted(26, 7) Source(1, 11) + SourceIndex(0) +5 >Emitted(26, 12) Source(1, 8) + SourceIndex(0) +6 >Emitted(26, 15) Source(1, 11) + SourceIndex(0) +7 >Emitted(26, 23) Source(19, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMap-Comments.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments.symbols b/tests/baselines/reference/sourceMap-Comments.symbols new file mode 100644 index 00000000000..d7c1adabbb0 --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/sourceMap-Comments.ts === +module sas.tools { +>sas : Symbol(sas, Decl(sourceMap-Comments.ts, 0, 0)) +>tools : Symbol(tools, Decl(sourceMap-Comments.ts, 0, 11)) + + export class Test { +>Test : Symbol(Test, Decl(sourceMap-Comments.ts, 0, 18)) + + public doX(): void { +>doX : Symbol(doX, Decl(sourceMap-Comments.ts, 1, 23)) + + let f: number = 2; +>f : Symbol(f, Decl(sourceMap-Comments.ts, 3, 15)) + + switch (f) { +>f : Symbol(f, Decl(sourceMap-Comments.ts, 3, 15)) + + case 1: + break; + case 2: + //line comment 1 + //line comment 2 + break; + case 3: + //a comment + break; + } + } + } + +} + diff --git a/tests/baselines/reference/sourceMap-Comments.types b/tests/baselines/reference/sourceMap-Comments.types new file mode 100644 index 00000000000..cbb58b67994 --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/sourceMap-Comments.ts === +module sas.tools { +>sas : typeof sas +>tools : typeof tools + + export class Test { +>Test : Test + + public doX(): void { +>doX : () => void + + let f: number = 2; +>f : number +>2 : number + + switch (f) { +>f : number + + case 1: +>1 : number + + break; + case 2: +>2 : number + + //line comment 1 + //line comment 2 + break; + case 3: +>3 : number + + //a comment + break; + } + } + } + +} + diff --git a/tests/baselines/reference/sourceMap-Comments2.js b/tests/baselines/reference/sourceMap-Comments2.js new file mode 100644 index 00000000000..cf03b015ace --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments2.js @@ -0,0 +1,39 @@ +//// [sourceMap-Comments2.ts] +function foo(str: string, num: number): void { + return; +} + +/** + * some sort of block quote + */ +function bar(str: string, num: number): void { + return; +} + +// some sort of comment +function baz(str: string, num: number): void { + return; +} + +function qat(str: string, num: number): void { + return; +} + +//// [sourceMap-Comments2.js] +function foo(str, num) { + return; +} +/** + * some sort of block quote + */ +function bar(str, num) { + return; +} +// some sort of comment +function baz(str, num) { + return; +} +function qat(str, num) { + return; +} +//# sourceMappingURL=sourceMap-Comments2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments2.js.map b/tests/baselines/reference/sourceMap-Comments2.js.map new file mode 100644 index 00000000000..be5a88d795d --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments2.js.map @@ -0,0 +1,2 @@ +//// [sourceMap-Comments2.js.map] +{"version":3,"file":"sourceMap-Comments2.js","sourceRoot":"","sources":["sourceMap-Comments2.ts"],"names":["foo","bar","baz","qat"],"mappings":"AAAA,aAAa,GAAW,EAAE,GAAW;IACjCA,MAAMA,CAACA;AACXA,CAACA;AAED;;GAEG;AACH,aAAa,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA;AAED,uBAAuB;AACvB,aAAa,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA;AAED,aAAa,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments2.sourcemap.txt b/tests/baselines/reference/sourceMap-Comments2.sourcemap.txt new file mode 100644 index 00000000000..d6230b83dfb --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments2.sourcemap.txt @@ -0,0 +1,199 @@ +=================================================================== +JsFile: sourceMap-Comments2.js +mapUrl: sourceMap-Comments2.js.map +sourceRoot: +sources: sourceMap-Comments2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMap-Comments2.js +sourceFile:sourceMap-Comments2.ts +------------------------------------------------------------------- +>>>function foo(str, num) { +1 > +2 >^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^^^ +1 > +2 >function foo( +3 > str: string +4 > , +5 > num: number +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 14) Source(1, 14) + SourceIndex(0) +3 >Emitted(1, 17) Source(1, 25) + SourceIndex(0) +4 >Emitted(1, 19) Source(1, 27) + SourceIndex(0) +5 >Emitted(1, 22) Source(1, 38) + SourceIndex(0) +--- +>>> return; +1 >^^^^ +2 > ^^^^^^ +3 > ^ +1 >): void { + > +2 > return +3 > ; +1 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (foo) +2 >Emitted(2, 11) Source(2, 11) + SourceIndex(0) name (foo) +3 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) name (foo) +--- +>>>} +1 > +2 >^ +3 > ^^^-> +1 > + > +2 >} +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) name (foo) +2 >Emitted(3, 2) Source(3, 2) + SourceIndex(0) name (foo) +--- +>>>/** +1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > + > +1->Emitted(4, 1) Source(5, 1) + SourceIndex(0) +--- +>>> * some sort of block quote +>>> */ +1->^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^-> +1->/** + > * some sort of block quote + > */ +1->Emitted(6, 4) Source(7, 4) + SourceIndex(0) +--- +>>>function bar(str, num) { +1-> +2 >^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^^^ +1-> + > +2 >function bar( +3 > str: string +4 > , +5 > num: number +1->Emitted(7, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(7, 14) Source(8, 14) + SourceIndex(0) +3 >Emitted(7, 17) Source(8, 25) + SourceIndex(0) +4 >Emitted(7, 19) Source(8, 27) + SourceIndex(0) +5 >Emitted(7, 22) Source(8, 38) + SourceIndex(0) +--- +>>> return; +1 >^^^^ +2 > ^^^^^^ +3 > ^ +1 >): void { + > +2 > return +3 > ; +1 >Emitted(8, 5) Source(9, 5) + SourceIndex(0) name (bar) +2 >Emitted(8, 11) Source(9, 11) + SourceIndex(0) name (bar) +3 >Emitted(8, 12) Source(9, 12) + SourceIndex(0) name (bar) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +1 >Emitted(9, 1) Source(10, 1) + SourceIndex(0) name (bar) +2 >Emitted(9, 2) Source(10, 2) + SourceIndex(0) name (bar) +--- +>>>// some sort of comment +1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^-> +1-> + > + > +2 >// some sort of comment +1->Emitted(10, 1) Source(12, 1) + SourceIndex(0) +2 >Emitted(10, 24) Source(12, 24) + SourceIndex(0) +--- +>>>function baz(str, num) { +1-> +2 >^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^^^ +1-> + > +2 >function baz( +3 > str: string +4 > , +5 > num: number +1->Emitted(11, 1) Source(13, 1) + SourceIndex(0) +2 >Emitted(11, 14) Source(13, 14) + SourceIndex(0) +3 >Emitted(11, 17) Source(13, 25) + SourceIndex(0) +4 >Emitted(11, 19) Source(13, 27) + SourceIndex(0) +5 >Emitted(11, 22) Source(13, 38) + SourceIndex(0) +--- +>>> return; +1 >^^^^ +2 > ^^^^^^ +3 > ^ +1 >): void { + > +2 > return +3 > ; +1 >Emitted(12, 5) Source(14, 5) + SourceIndex(0) name (baz) +2 >Emitted(12, 11) Source(14, 11) + SourceIndex(0) name (baz) +3 >Emitted(12, 12) Source(14, 12) + SourceIndex(0) name (baz) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +1 >Emitted(13, 1) Source(15, 1) + SourceIndex(0) name (baz) +2 >Emitted(13, 2) Source(15, 2) + SourceIndex(0) name (baz) +--- +>>>function qat(str, num) { +1-> +2 >^^^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^^^ +1-> + > + > +2 >function qat( +3 > str: string +4 > , +5 > num: number +1->Emitted(14, 1) Source(17, 1) + SourceIndex(0) +2 >Emitted(14, 14) Source(17, 14) + SourceIndex(0) +3 >Emitted(14, 17) Source(17, 25) + SourceIndex(0) +4 >Emitted(14, 19) Source(17, 27) + SourceIndex(0) +5 >Emitted(14, 22) Source(17, 38) + SourceIndex(0) +--- +>>> return; +1 >^^^^ +2 > ^^^^^^ +3 > ^ +1 >): void { + > +2 > return +3 > ; +1 >Emitted(15, 5) Source(18, 5) + SourceIndex(0) name (qat) +2 >Emitted(15, 11) Source(18, 11) + SourceIndex(0) name (qat) +3 >Emitted(15, 12) Source(18, 12) + SourceIndex(0) name (qat) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +1 >Emitted(16, 1) Source(19, 1) + SourceIndex(0) name (qat) +2 >Emitted(16, 2) Source(19, 2) + SourceIndex(0) name (qat) +--- +>>>//# sourceMappingURL=sourceMap-Comments2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comments2.symbols b/tests/baselines/reference/sourceMap-Comments2.symbols new file mode 100644 index 00000000000..f77772d483f --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments2.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/sourceMap-Comments2.ts === +function foo(str: string, num: number): void { +>foo : Symbol(foo, Decl(sourceMap-Comments2.ts, 0, 0)) +>str : Symbol(str, Decl(sourceMap-Comments2.ts, 0, 13)) +>num : Symbol(num, Decl(sourceMap-Comments2.ts, 0, 25)) + + return; +} + +/** + * some sort of block quote + */ +function bar(str: string, num: number): void { +>bar : Symbol(bar, Decl(sourceMap-Comments2.ts, 2, 1)) +>str : Symbol(str, Decl(sourceMap-Comments2.ts, 7, 13)) +>num : Symbol(num, Decl(sourceMap-Comments2.ts, 7, 25)) + + return; +} + +// some sort of comment +function baz(str: string, num: number): void { +>baz : Symbol(baz, Decl(sourceMap-Comments2.ts, 9, 1)) +>str : Symbol(str, Decl(sourceMap-Comments2.ts, 12, 13)) +>num : Symbol(num, Decl(sourceMap-Comments2.ts, 12, 25)) + + return; +} + +function qat(str: string, num: number): void { +>qat : Symbol(qat, Decl(sourceMap-Comments2.ts, 14, 1)) +>str : Symbol(str, Decl(sourceMap-Comments2.ts, 16, 13)) +>num : Symbol(num, Decl(sourceMap-Comments2.ts, 16, 25)) + + return; +} diff --git a/tests/baselines/reference/sourceMap-Comments2.types b/tests/baselines/reference/sourceMap-Comments2.types new file mode 100644 index 00000000000..d8d44581239 --- /dev/null +++ b/tests/baselines/reference/sourceMap-Comments2.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/sourceMap-Comments2.ts === +function foo(str: string, num: number): void { +>foo : (str: string, num: number) => void +>str : string +>num : number + + return; +} + +/** + * some sort of block quote + */ +function bar(str: string, num: number): void { +>bar : (str: string, num: number) => void +>str : string +>num : number + + return; +} + +// some sort of comment +function baz(str: string, num: number): void { +>baz : (str: string, num: number) => void +>str : string +>num : number + + return; +} + +function qat(str: string, num: number): void { +>qat : (str: string, num: number) => void +>str : string +>num : number + + return; +} diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js.map b/tests/baselines/reference/sourceMap-FileWithComments.js.map index fc27b8542d0..7e38a53a902 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js.map +++ b/tests/baselines/reference/sourceMap-FileWithComments.js.map @@ -1,2 +1,2 @@ //// [sourceMap-FileWithComments.js.map] -{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":["Shapes","Shapes.Point","Shapes.Point.constructor","Shapes.Point.getDist","Shapes.foo"],"mappings":"AAOA,AADA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAGXA,AADAA,QAAQA;;QAEJC,cAAcA;QACdA,eAAmBA,CAASA,EAASA,CAASA;YAA3BC,MAACA,GAADA,CAACA,CAAQA;YAASA,MAACA,GAADA,CAACA,CAAQA;QAAIA,CAACA;QAEnDD,kBAAkBA;QAClBA,uBAAOA,GAAPA,cAAYE,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;QAElEF,gBAAgBA;QACTA,YAAMA,GAAGA,IAAIA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA,CAACA;QACpCA,YAACA;IAADA,CAACA,AATDD,IASCA;IATYA,YAAKA,QASjBA,CAAAA;IAGDA,AADAA,+BAA+BA;QAC3BA,CAACA,GAAGA,EAAEA,CAACA;IAEXA;IACAI,CAACA;IADeJ,UAAGA,MAClBA,CAAAA;IAKDA,AAHAA;;MAEEA;QACEA,CAACA,GAAGA,EAAEA,CAACA;AACfA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAGD,AADA,qBAAqB;IACjB,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":["Shapes","Shapes.Point","Shapes.Point.constructor","Shapes.Point.getDist","Shapes.foo"],"mappings":"AAMA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAEXA,QAAQA;IACRA;QACIC,cAAcA;QACdA,eAAmBA,CAASA,EAASA,CAASA;YAA3BC,MAACA,GAADA,CAACA,CAAQA;YAASA,MAACA,GAADA,CAACA,CAAQA;QAAIA,CAACA;QAEnDD,kBAAkBA;QAClBA,uBAAOA,GAAPA,cAAYE,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;QAElEF,gBAAgBA;QACTA,YAAMA,GAAGA,IAAIA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA,CAACA;QACpCA,YAACA;IAADA,CAACA,AATDD,IASCA;IATYA,YAAKA,QASjBA,CAAAA;IAEDA,+BAA+BA;IAC/BA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IAEXA;IACAI,CAACA;IADeJ,UAAGA,MAClBA,CAAAA;IAEDA;;MAEEA;IACFA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;AACfA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAED,qBAAqB;AACrB,IAAI,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt index 8283006042a..8f8fd8e84b3 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt @@ -10,22 +10,18 @@ sourceFile:sourceMap-FileWithComments.ts ------------------------------------------------------------------- >>>// Module 1 > -2 > -3 >^^^^^^^^^ -4 > ^^^-> +2 >^^^^^^^^^ +3 > ^^^-> 1 > >// Interface >interface IPoint { > getDist(): number; >} > - >// Module > -2 > -3 >// Module -1 >Emitted(1, 1) Source(8, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(7, 1) + SourceIndex(0) -3 >Emitted(1, 10) Source(7, 10) + SourceIndex(0) +2 >// Module +1 >Emitted(1, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(1, 10) Source(7, 10) + SourceIndex(0) --- >>>var Shapes; 1-> @@ -86,26 +82,27 @@ sourceFile:sourceMap-FileWithComments.ts --- >>> // Class 1 >^^^^ -2 > -3 > ^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^-> 1 > > - > // Class > -2 > -3 > // Class -1 >Emitted(4, 5) Source(11, 5) + SourceIndex(0) name (Shapes) -2 >Emitted(4, 5) Source(10, 5) + SourceIndex(0) name (Shapes) -3 >Emitted(4, 13) Source(10, 13) + SourceIndex(0) name (Shapes) +2 > // Class +1 >Emitted(4, 5) Source(10, 5) + SourceIndex(0) name (Shapes) +2 >Emitted(4, 13) Source(10, 13) + SourceIndex(0) name (Shapes) --- >>> var Point = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(5, 5) Source(11, 5) + SourceIndex(0) name (Shapes) +--- >>> // Constructor 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^ 3 > ^^^^^^^^^-> -1-> - > export class Point implements IPoint { +1->export class Point implements IPoint { > 2 > // Constructor 1->Emitted(6, 9) Source(12, 9) + SourceIndex(0) name (Shapes.Point) @@ -380,36 +377,35 @@ sourceFile:sourceMap-FileWithComments.ts --- >>> // Variable comment after class 1->^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Variable comment after class > -2 > -3 > // Variable comment after class -1->Emitted(18, 5) Source(23, 5) + SourceIndex(0) name (Shapes) -2 >Emitted(18, 5) Source(22, 5) + SourceIndex(0) name (Shapes) -3 >Emitted(18, 36) Source(22, 36) + SourceIndex(0) name (Shapes) +2 > // Variable comment after class +1->Emitted(18, 5) Source(22, 5) + SourceIndex(0) name (Shapes) +2 >Emitted(18, 36) Source(22, 36) + SourceIndex(0) name (Shapes) --- >>> var a = 10; -1 >^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^-> +1 >^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^-> 1 > - > var -2 > a -3 > = -4 > 10 -5 > ; -1 >Emitted(19, 9) Source(23, 9) + SourceIndex(0) name (Shapes) -2 >Emitted(19, 10) Source(23, 10) + SourceIndex(0) name (Shapes) -3 >Emitted(19, 13) Source(23, 13) + SourceIndex(0) name (Shapes) -4 >Emitted(19, 15) Source(23, 15) + SourceIndex(0) name (Shapes) -5 >Emitted(19, 16) Source(23, 16) + SourceIndex(0) name (Shapes) + > +2 > var +3 > a +4 > = +5 > 10 +6 > ; +1 >Emitted(19, 5) Source(23, 5) + SourceIndex(0) name (Shapes) +2 >Emitted(19, 9) Source(23, 9) + SourceIndex(0) name (Shapes) +3 >Emitted(19, 10) Source(23, 10) + SourceIndex(0) name (Shapes) +4 >Emitted(19, 13) Source(23, 13) + SourceIndex(0) name (Shapes) +5 >Emitted(19, 15) Source(23, 15) + SourceIndex(0) name (Shapes) +6 >Emitted(19, 16) Source(23, 16) + SourceIndex(0) name (Shapes) --- >>> function foo() { 1->^^^^ @@ -447,17 +443,11 @@ sourceFile:sourceMap-FileWithComments.ts --- >>> /** comment after function 1->^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > - > /** comment after function - > * this is another comment - > */ > -2 > -1->Emitted(23, 5) Source(31, 5) + SourceIndex(0) name (Shapes) -2 >Emitted(23, 5) Source(28, 5) + SourceIndex(0) name (Shapes) +1->Emitted(23, 5) Source(28, 5) + SourceIndex(0) name (Shapes) --- >>> * this is another comment >>> */ @@ -469,23 +459,26 @@ sourceFile:sourceMap-FileWithComments.ts 1->Emitted(25, 7) Source(30, 7) + SourceIndex(0) name (Shapes) --- >>> var b = 10; -1->^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^-> +1->^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^^^^^^^^^^^^-> 1-> - > var -2 > b -3 > = -4 > 10 -5 > ; -1->Emitted(26, 9) Source(31, 9) + SourceIndex(0) name (Shapes) -2 >Emitted(26, 10) Source(31, 10) + SourceIndex(0) name (Shapes) -3 >Emitted(26, 13) Source(31, 13) + SourceIndex(0) name (Shapes) -4 >Emitted(26, 15) Source(31, 15) + SourceIndex(0) name (Shapes) -5 >Emitted(26, 16) Source(31, 16) + SourceIndex(0) name (Shapes) + > +2 > var +3 > b +4 > = +5 > 10 +6 > ; +1->Emitted(26, 5) Source(31, 5) + SourceIndex(0) name (Shapes) +2 >Emitted(26, 9) Source(31, 9) + SourceIndex(0) name (Shapes) +3 >Emitted(26, 10) Source(31, 10) + SourceIndex(0) name (Shapes) +4 >Emitted(26, 13) Source(31, 13) + SourceIndex(0) name (Shapes) +5 >Emitted(26, 15) Source(31, 15) + SourceIndex(0) name (Shapes) +6 >Emitted(26, 16) Source(31, 16) + SourceIndex(0) name (Shapes) --- >>>})(Shapes || (Shapes = {})); 1-> @@ -537,60 +530,59 @@ sourceFile:sourceMap-FileWithComments.ts --- >>>/** Local Variable */ 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^-> 1 > > - >/** Local Variable */ > -2 > -3 >/** Local Variable */ -1 >Emitted(28, 1) Source(35, 1) + SourceIndex(0) -2 >Emitted(28, 1) Source(34, 1) + SourceIndex(0) -3 >Emitted(28, 22) Source(34, 22) + SourceIndex(0) +2 >/** Local Variable */ +1 >Emitted(28, 1) Source(34, 1) + SourceIndex(0) +2 >Emitted(28, 22) Source(34, 22) + SourceIndex(0) --- >>>var p = new Shapes.Point(3, 4); -1->^^^^ -2 > ^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^^ -6 > ^ -7 > ^^^^^ -8 > ^ -9 > ^ -10> ^^ -11> ^ -12> ^ -13> ^ +1-> +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^^^^ +6 > ^^^^^^ +7 > ^ +8 > ^^^^^ +9 > ^ +10> ^ +11> ^^ +12> ^ +13> ^ +14> ^ 1-> - >var -2 > p -3 > : IPoint = -4 > new -5 > Shapes -6 > . -7 > Point -8 > ( -9 > 3 -10> , -11> 4 -12> ) -13> ; -1->Emitted(29, 5) Source(35, 5) + SourceIndex(0) -2 >Emitted(29, 6) Source(35, 6) + SourceIndex(0) -3 >Emitted(29, 9) Source(35, 17) + SourceIndex(0) -4 >Emitted(29, 13) Source(35, 21) + SourceIndex(0) -5 >Emitted(29, 19) Source(35, 27) + SourceIndex(0) -6 >Emitted(29, 20) Source(35, 28) + SourceIndex(0) -7 >Emitted(29, 25) Source(35, 33) + SourceIndex(0) -8 >Emitted(29, 26) Source(35, 34) + SourceIndex(0) -9 >Emitted(29, 27) Source(35, 35) + SourceIndex(0) -10>Emitted(29, 29) Source(35, 37) + SourceIndex(0) -11>Emitted(29, 30) Source(35, 38) + SourceIndex(0) -12>Emitted(29, 31) Source(35, 39) + SourceIndex(0) -13>Emitted(29, 32) Source(35, 40) + SourceIndex(0) + > +2 >var +3 > p +4 > : IPoint = +5 > new +6 > Shapes +7 > . +8 > Point +9 > ( +10> 3 +11> , +12> 4 +13> ) +14> ; +1->Emitted(29, 1) Source(35, 1) + SourceIndex(0) +2 >Emitted(29, 5) Source(35, 5) + SourceIndex(0) +3 >Emitted(29, 6) Source(35, 6) + SourceIndex(0) +4 >Emitted(29, 9) Source(35, 17) + SourceIndex(0) +5 >Emitted(29, 13) Source(35, 21) + SourceIndex(0) +6 >Emitted(29, 19) Source(35, 27) + SourceIndex(0) +7 >Emitted(29, 20) Source(35, 28) + SourceIndex(0) +8 >Emitted(29, 25) Source(35, 33) + SourceIndex(0) +9 >Emitted(29, 26) Source(35, 34) + SourceIndex(0) +10>Emitted(29, 27) Source(35, 35) + SourceIndex(0) +11>Emitted(29, 29) Source(35, 37) + SourceIndex(0) +12>Emitted(29, 30) Source(35, 38) + SourceIndex(0) +13>Emitted(29, 31) Source(35, 39) + SourceIndex(0) +14>Emitted(29, 32) Source(35, 40) + SourceIndex(0) --- >>>var dist = p.getDist(); 1 > diff --git a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js.map b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js.map index 217105d88d2..7f660400470 100644 --- a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js.map +++ b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js.map @@ -1,2 +1,2 @@ //// [sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js.map] -{"version":3,"file":"sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js","sourceRoot":"","sources":["sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.ts"],"names":["Q","Q.P"],"mappings":"AAAA,IAAO,CAAC,CAKP;AALD,WAAO,CAAC,EAAC,CAAC;IACNA;QAEIC,AADAA,YAAYA;YACRA,CAACA,GAAGA,CAACA,CAACA;IACdA,CAACA;AACLD,CAACA,EALM,CAAC,KAAD,CAAC,QAKP"} \ No newline at end of file +{"version":3,"file":"sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.js","sourceRoot":"","sources":["sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.ts"],"names":["Q","Q.P"],"mappings":"AAAA,IAAO,CAAC,CAKP;AALD,WAAO,CAAC,EAAC,CAAC;IACNA;QACIC,YAAYA;QACZA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACdA,CAACA;AACLD,CAACA,EALM,CAAC,KAAD,CAAC,QAKP"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.sourcemap.txt b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.sourcemap.txt index 669481b46a2..5413f4bbc23 100644 --- a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.sourcemap.txt +++ b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.sourcemap.txt @@ -55,34 +55,33 @@ sourceFile:sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.t --- >>> // Test this 1->^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^ 1->function P() { - > // Test this > -2 > -3 > // Test this -1->Emitted(4, 9) Source(4, 9) + SourceIndex(0) name (Q.P) -2 >Emitted(4, 9) Source(3, 9) + SourceIndex(0) name (Q.P) -3 >Emitted(4, 21) Source(3, 21) + SourceIndex(0) name (Q.P) +2 > // Test this +1->Emitted(4, 9) Source(3, 9) + SourceIndex(0) name (Q.P) +2 >Emitted(4, 21) Source(3, 21) + SourceIndex(0) name (Q.P) --- >>> var a = 1; -1 >^^^^^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^ -5 > ^ +1 >^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ 1 > - > var -2 > a -3 > = -4 > 1 -5 > ; -1 >Emitted(5, 13) Source(4, 13) + SourceIndex(0) name (Q.P) -2 >Emitted(5, 14) Source(4, 14) + SourceIndex(0) name (Q.P) -3 >Emitted(5, 17) Source(4, 17) + SourceIndex(0) name (Q.P) -4 >Emitted(5, 18) Source(4, 18) + SourceIndex(0) name (Q.P) -5 >Emitted(5, 19) Source(4, 19) + SourceIndex(0) name (Q.P) + > +2 > var +3 > a +4 > = +5 > 1 +6 > ; +1 >Emitted(5, 9) Source(4, 9) + SourceIndex(0) name (Q.P) +2 >Emitted(5, 13) Source(4, 13) + SourceIndex(0) name (Q.P) +3 >Emitted(5, 14) Source(4, 14) + SourceIndex(0) name (Q.P) +4 >Emitted(5, 17) Source(4, 17) + SourceIndex(0) name (Q.P) +5 >Emitted(5, 18) Source(4, 18) + SourceIndex(0) name (Q.P) +6 >Emitted(5, 19) Source(4, 19) + SourceIndex(0) name (Q.P) --- >>> } 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.js.map b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.js.map index 7a84caf3879..bdfba243ab6 100644 --- a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.js.map +++ b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.js.map @@ -1,2 +1,2 @@ //// [sourceMapForFunctionWithCommentPrecedingStatement01.js.map] -{"version":3,"file":"sourceMapForFunctionWithCommentPrecedingStatement01.js","sourceRoot":"","sources":["sourceMapForFunctionWithCommentPrecedingStatement01.ts"],"names":["P"],"mappings":"AAAA;IAEIA,AADAA,YAAYA;QACRA,CAACA,GAAGA,CAACA,CAACA;AACdA,CAACA"} \ No newline at end of file +{"version":3,"file":"sourceMapForFunctionWithCommentPrecedingStatement01.js","sourceRoot":"","sources":["sourceMapForFunctionWithCommentPrecedingStatement01.ts"],"names":["P"],"mappings":"AAAA;IACIA,YAAYA;IACZA,IAAIA,CAACA,GAAGA,CAACA,CAACA;AACdA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.sourcemap.txt b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.sourcemap.txt index cbeed192d31..65037c69437 100644 --- a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.sourcemap.txt +++ b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.sourcemap.txt @@ -16,34 +16,33 @@ sourceFile:sourceMapForFunctionWithCommentPrecedingStatement01.ts --- >>> // Test this 1->^^^^ -2 > -3 > ^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^ 1->function P() { - > // Test this > -2 > -3 > // Test this -1->Emitted(2, 5) Source(3, 5) + SourceIndex(0) name (P) -2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (P) -3 >Emitted(2, 17) Source(2, 17) + SourceIndex(0) name (P) +2 > // Test this +1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (P) +2 >Emitted(2, 17) Source(2, 17) + SourceIndex(0) name (P) --- >>> var a = 1; -1 >^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^ -5 > ^ +1 >^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ 1 > - > var -2 > a -3 > = -4 > 1 -5 > ; -1 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (P) -2 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) name (P) -3 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) name (P) -4 >Emitted(3, 14) Source(3, 14) + SourceIndex(0) name (P) -5 >Emitted(3, 15) Source(3, 15) + SourceIndex(0) name (P) + > +2 > var +3 > a +4 > = +5 > 1 +6 > ; +1 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) name (P) +2 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (P) +3 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) name (P) +4 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) name (P) +5 >Emitted(3, 14) Source(3, 14) + SourceIndex(0) name (P) +6 >Emitted(3, 15) Source(3, 15) + SourceIndex(0) name (P) --- >>>} 1 > diff --git a/tests/baselines/reference/sourceMapValidationClasses.js.map b/tests/baselines/reference/sourceMapValidationClasses.js.map index e3ffe2de454..fcba248ef1a 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.js.map +++ b/tests/baselines/reference/sourceMapValidationClasses.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClasses.js.map] -{"version":3,"file":"sourceMapValidationClasses.js","sourceRoot":"","sources":["sourceMapValidationClasses.ts"],"names":["Foo","Foo.Bar","Foo.Bar.Greeter","Foo.Bar.Greeter.constructor","Foo.Bar.Greeter.greet","Foo.Bar.foo","Foo.Bar.foo2"],"mappings":"AAAA,IAAO,GAAG,CAmCT;AAnCD,WAAO,GAAG;IAACA,IAAAA,GAAGA,CAmCbA;IAnCUA,WAAAA,GAAGA,EAACA,CAACA;QACZC,YAAYA,CAACA;QAEbA;YACIC,iBAAmBA,QAAgBA;gBAAhBC,aAAQA,GAARA,QAAQA,CAAQA;YACnCA,CAACA;YAEDD,uBAAKA,GAALA;gBACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;YAC5CA,CAACA;YACLF,cAACA;QAADA,CAACA,AAPDD,IAOCA;QAGDA,aAAaA,QAAgBA;YACzBI,MAAMA,CAACA,IAAIA,OAAOA,CAACA,QAAQA,CAACA,CAACA;QACjCA,CAACA;QAEDJ,IAAIA,OAAOA,GAAGA,IAAIA,OAAOA,CAACA,eAAeA,CAACA,CAACA;QAC3CA,IAAIA,GAAGA,GAAGA,OAAOA,CAACA,KAAKA,EAAEA,CAACA;QAE1BA,cAAcA,QAAgBA;YAAEK,kBAAiBA,mBAAmBA,MAAUA;iBAA9CA,WAA8CA,CAA9CA,sBAA8CA,CAA9CA,IAA8CA;gBAA9CA,cAAiBA,mBAAmBA,yBAAUA;;YAC1EA,IAAIA,QAAQA,GAAcA,EAAEA,EAAEA,0BAA0BA,AAA3BA;YAC7BA,QAAQA,CAACA,CAACA,CAACA,GAAGA,IAAIA,OAAOA,CAACA,QAAQA,CAACA,CAACA;YACpCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,aAAaA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;gBAC5CA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,OAAOA,CAACA,aAAaA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YACjDA,CAACA;YAEDA,MAAMA,CAACA,QAAQA,CAACA;QACpBA,CAACA;QAEDL,IAAIA,CAACA,GAAGA,IAAIA,CAACA,OAAOA,EAAEA,OAAOA,EAAEA,GAAGA,CAACA,CAACA;QAEpCA,AADAA,qCAAqCA;QACrCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,CAACA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;YAChCA,CAACA,CAACA,CAACA,CAACA,CAACA,KAAKA,EAAEA,CAACA;QACjBA,CAACA;IACLA,CAACA,EAnCUD,GAAGA,GAAHA,OAAGA,KAAHA,OAAGA,QAmCbA;AAADA,CAACA,EAnCM,GAAG,KAAH,GAAG,QAmCT"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClasses.js","sourceRoot":"","sources":["sourceMapValidationClasses.ts"],"names":["Foo","Foo.Bar","Foo.Bar.Greeter","Foo.Bar.Greeter.constructor","Foo.Bar.Greeter.greet","Foo.Bar.foo","Foo.Bar.foo2"],"mappings":"AAAA,IAAO,GAAG,CAmCT;AAnCD,WAAO,GAAG;IAACA,IAAAA,GAAGA,CAmCbA;IAnCUA,WAAAA,GAAGA,EAACA,CAACA;QACZC,YAAYA,CAACA;QAEbA;YACIC,iBAAmBA,QAAgBA;gBAAhBC,aAAQA,GAARA,QAAQA,CAAQA;YACnCA,CAACA;YAEDD,uBAAKA,GAALA;gBACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;YAC5CA,CAACA;YACLF,cAACA;QAADA,CAACA,AAPDD,IAOCA;QAGDA,aAAaA,QAAgBA;YACzBI,MAAMA,CAACA,IAAIA,OAAOA,CAACA,QAAQA,CAACA,CAACA;QACjCA,CAACA;QAEDJ,IAAIA,OAAOA,GAAGA,IAAIA,OAAOA,CAACA,eAAeA,CAACA,CAACA;QAC3CA,IAAIA,GAAGA,GAAGA,OAAOA,CAACA,KAAKA,EAAEA,CAACA;QAE1BA,cAAcA,QAAgBA;YAAEK,kBAAiBA,mBAAmBA,MAAUA;iBAA9CA,WAA8CA,CAA9CA,sBAA8CA,CAA9CA,IAA8CA;gBAA9CA,cAAiBA,mBAAmBA,yBAAUA;;YAC1EA,IAAIA,QAAQA,GAAcA,EAAEA,CAACA,CAACA,0BAA0BA;YACxDA,QAAQA,CAACA,CAACA,CAACA,GAAGA,IAAIA,OAAOA,CAACA,QAAQA,CAACA,CAACA;YACpCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,aAAaA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;gBAC5CA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,OAAOA,CAACA,aAAaA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YACjDA,CAACA;YAEDA,MAAMA,CAACA,QAAQA,CAACA;QACpBA,CAACA;QAEDL,IAAIA,CAACA,GAAGA,IAAIA,CAACA,OAAOA,EAAEA,OAAOA,EAAEA,GAAGA,CAACA,CAACA;QACpCA,qCAAqCA;QACrCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,CAACA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;YAChCA,CAACA,CAACA,CAACA,CAACA,CAACA,KAAKA,EAAEA,CAACA;QACjBA,CAACA;IACLA,CAACA,EAnCUD,GAAGA,GAAHA,OAAGA,KAAHA,OAAGA,QAmCbA;AAADA,CAACA,EAnCM,GAAG,KAAH,GAAG,QAmCT"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt index 6d937785cc8..4eb5e300422 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt @@ -479,26 +479,26 @@ sourceFile:sourceMapValidationClasses.ts 3 > ^^^^^^^^ 4 > ^^^ 5 > ^^ -6 > ^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -8 > +6 > ^ +7 > ^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 >) { > 2 > var 3 > greeters 4 > : Greeter[] = 5 > [] -6 > ; -7 > /* inline block comment */ -8 > +6 > ; +7 > +8 > /* inline block comment */ 1 >Emitted(25, 13) Source(22, 9) + SourceIndex(0) name (Foo.Bar.foo2) 2 >Emitted(25, 17) Source(22, 13) + SourceIndex(0) name (Foo.Bar.foo2) 3 >Emitted(25, 25) Source(22, 21) + SourceIndex(0) name (Foo.Bar.foo2) 4 >Emitted(25, 28) Source(22, 35) + SourceIndex(0) name (Foo.Bar.foo2) 5 >Emitted(25, 30) Source(22, 37) + SourceIndex(0) name (Foo.Bar.foo2) -6 >Emitted(25, 32) Source(22, 39) + SourceIndex(0) name (Foo.Bar.foo2) -7 >Emitted(25, 58) Source(22, 65) + SourceIndex(0) name (Foo.Bar.foo2) -8 >Emitted(25, 58) Source(22, 38) + SourceIndex(0) name (Foo.Bar.foo2) +6 >Emitted(25, 31) Source(22, 38) + SourceIndex(0) name (Foo.Bar.foo2) +7 >Emitted(25, 32) Source(22, 39) + SourceIndex(0) name (Foo.Bar.foo2) +8 >Emitted(25, 58) Source(22, 65) + SourceIndex(0) name (Foo.Bar.foo2) --- >>> greeters[0] = new Greeter(greeting); 1 >^^^^^^^^^^^^ @@ -514,7 +514,7 @@ sourceFile:sourceMapValidationClasses.ts 11> ^ 12> ^ 13> ^^^^^^^^^^^^^-> -1 > /* inline block comment */ +1 > > 2 > greeters 3 > [ @@ -737,16 +737,12 @@ sourceFile:sourceMapValidationClasses.ts --- >>> // This is simple signle line comment 1->^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> - > // This is simple signle line comment > -2 > -3 > // This is simple signle line comment -1->Emitted(33, 9) Source(33, 5) + SourceIndex(0) name (Foo.Bar) -2 >Emitted(33, 9) Source(32, 5) + SourceIndex(0) name (Foo.Bar) -3 >Emitted(33, 46) Source(32, 42) + SourceIndex(0) name (Foo.Bar) +2 > // This is simple signle line comment +1->Emitted(33, 9) Source(32, 5) + SourceIndex(0) name (Foo.Bar) +2 >Emitted(33, 46) Source(32, 42) + SourceIndex(0) name (Foo.Bar) --- >>> for (var j = 0; j < b.length; j++) { 1 >^^^^^^^^ diff --git a/tests/baselines/reference/sourceMapValidationExportAssignment.js.map b/tests/baselines/reference/sourceMapValidationExportAssignment.js.map index 2846bc70e06..9ec681ced52 100644 --- a/tests/baselines/reference/sourceMapValidationExportAssignment.js.map +++ b/tests/baselines/reference/sourceMapValidationExportAssignment.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationExportAssignment.js.map] -{"version":3,"file":"sourceMapValidationExportAssignment.js","sourceRoot":"","sources":["sourceMapValidationExportAssignment.ts"],"names":["a","a.constructor"],"mappings":";IAAA;QAAAA;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IACU,AAAX,OAAS,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationExportAssignment.js","sourceRoot":"","sources":["sourceMapValidationExportAssignment.ts"],"names":["a","a.constructor"],"mappings":";IAAA;QAAAA;QAEAC,CAACA;QAADD,QAACA;IAADA,CAACA,AAFD,IAEC;IACD,OAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationExportAssignment.sourcemap.txt b/tests/baselines/reference/sourceMapValidationExportAssignment.sourcemap.txt index 58810df106b..cf4adb6d5ea 100644 --- a/tests/baselines/reference/sourceMapValidationExportAssignment.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationExportAssignment.sourcemap.txt @@ -59,21 +59,18 @@ sourceFile:sourceMapValidationExportAssignment.ts --- >>> return a; 1->^^^^ -2 > -3 > ^^^^^^^ -4 > ^ -5 > ^ +2 > ^^^^^^^ +3 > ^ +4 > ^ 1-> - >export = a; -2 > -3 > export = -4 > a -5 > ; -1->Emitted(7, 5) Source(4, 12) + SourceIndex(0) -2 >Emitted(7, 5) Source(4, 1) + SourceIndex(0) -3 >Emitted(7, 12) Source(4, 10) + SourceIndex(0) -4 >Emitted(7, 13) Source(4, 11) + SourceIndex(0) -5 >Emitted(7, 14) Source(4, 12) + SourceIndex(0) + > +2 > export = +3 > a +4 > ; +1->Emitted(7, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(7, 12) Source(4, 10) + SourceIndex(0) +3 >Emitted(7, 13) Source(4, 11) + SourceIndex(0) +4 >Emitted(7, 14) Source(4, 12) + SourceIndex(0) --- >>>}); >>>//# sourceMappingURL=sourceMapValidationExportAssignment.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.js.map b/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.js.map index f3d29aaebf8..6da5d0f075e 100644 --- a/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.js.map +++ b/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationExportAssignmentCommonjs.js.map] -{"version":3,"file":"sourceMapValidationExportAssignmentCommonjs.js","sourceRoot":"","sources":["sourceMapValidationExportAssignmentCommonjs.ts"],"names":["a","a.constructor"],"mappings":"AAAA;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC;AACU,AAAX,iBAAS,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationExportAssignmentCommonjs.js","sourceRoot":"","sources":["sourceMapValidationExportAssignmentCommonjs.ts"],"names":["a","a.constructor"],"mappings":"AAAA;IAAAA;IAEAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAFD,IAEC;AACD,iBAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.sourcemap.txt b/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.sourcemap.txt index a78364591f9..fc7862c8ad4 100644 --- a/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationExportAssignmentCommonjs.sourcemap.txt @@ -58,21 +58,18 @@ sourceFile:sourceMapValidationExportAssignmentCommonjs.ts --- >>>module.exports = a; 1-> -2 > -3 >^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> - >export = a; -2 > -3 >export = -4 > a -5 > ; -1->Emitted(6, 1) Source(4, 12) + SourceIndex(0) -2 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) -3 >Emitted(6, 18) Source(4, 10) + SourceIndex(0) -4 >Emitted(6, 19) Source(4, 11) + SourceIndex(0) -5 >Emitted(6, 20) Source(4, 12) + SourceIndex(0) + > +2 >export = +3 > a +4 > ; +1->Emitted(6, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(6, 18) Source(4, 10) + SourceIndex(0) +3 >Emitted(6, 19) Source(4, 11) + SourceIndex(0) +4 >Emitted(6, 20) Source(4, 12) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationExportAssignmentCommonjs.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationWithComments.js.map b/tests/baselines/reference/sourceMapValidationWithComments.js.map index fe250495802..59c8ee5748e 100644 --- a/tests/baselines/reference/sourceMapValidationWithComments.js.map +++ b/tests/baselines/reference/sourceMapValidationWithComments.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationWithComments.js.map] -{"version":3,"file":"sourceMapValidationWithComments.js","sourceRoot":"","sources":["sourceMapValidationWithComments.ts"],"names":["DebugClass","DebugClass.constructor","DebugClass.debugFunc"],"mappings":"AAAA;IAAAA;IAoBAC,CAACA;IAlBiBD,oBAASA,GAAvBA;QAGIE,AADAA,2BAA2BA;YACvBA,CAACA,GAAGA,CAACA,CAACA;QACVA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QAIJA,AAHAA,yBAAyBA;QAGzBA,MAAMA,CAACA,IAAIA,CAACA;IAChBA,CAACA;IACLF,iBAACA;AAADA,CAACA,AApBD,IAoBC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationWithComments.js","sourceRoot":"","sources":["sourceMapValidationWithComments.ts"],"names":["DebugClass","DebugClass.constructor","DebugClass.debugFunc"],"mappings":"AAAA;IAAAA;IAoBAC,CAACA;IAlBiBD,oBAASA,GAAvBA;QAEIE,2BAA2BA;QAC3BA,IAAIA,CAACA,GAAGA,CAACA,CAACA;QACVA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,CAACA;QACJA,yBAAyBA;QAGzBA,MAAMA,CAACA,IAAIA,CAACA;IAChBA,CAACA;IACLF,iBAACA;AAADA,CAACA,AApBD,IAoBC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationWithComments.sourcemap.txt b/tests/baselines/reference/sourceMapValidationWithComments.sourcemap.txt index 5d2716cd127..239a418183f 100644 --- a/tests/baselines/reference/sourceMapValidationWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationWithComments.sourcemap.txt @@ -63,35 +63,34 @@ sourceFile:sourceMapValidationWithComments.ts --- >>> // Start Debugger Test Code 1->^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->public static debugFunc() { > - > // Start Debugger Test Code > -2 > -3 > // Start Debugger Test Code -1->Emitted(5, 9) Source(6, 9) + SourceIndex(0) name (DebugClass.debugFunc) -2 >Emitted(5, 9) Source(5, 9) + SourceIndex(0) name (DebugClass.debugFunc) -3 >Emitted(5, 36) Source(5, 36) + SourceIndex(0) name (DebugClass.debugFunc) +2 > // Start Debugger Test Code +1->Emitted(5, 9) Source(5, 9) + SourceIndex(0) name (DebugClass.debugFunc) +2 >Emitted(5, 36) Source(5, 36) + SourceIndex(0) name (DebugClass.debugFunc) --- >>> var i = 0; -1 >^^^^^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^ -5 > ^ +1 >^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ 1 > - > var -2 > i -3 > = -4 > 0 -5 > ; -1 >Emitted(6, 13) Source(6, 13) + SourceIndex(0) name (DebugClass.debugFunc) -2 >Emitted(6, 14) Source(6, 14) + SourceIndex(0) name (DebugClass.debugFunc) -3 >Emitted(6, 17) Source(6, 17) + SourceIndex(0) name (DebugClass.debugFunc) -4 >Emitted(6, 18) Source(6, 18) + SourceIndex(0) name (DebugClass.debugFunc) -5 >Emitted(6, 19) Source(6, 19) + SourceIndex(0) name (DebugClass.debugFunc) + > +2 > var +3 > i +4 > = +5 > 0 +6 > ; +1 >Emitted(6, 9) Source(6, 9) + SourceIndex(0) name (DebugClass.debugFunc) +2 >Emitted(6, 13) Source(6, 13) + SourceIndex(0) name (DebugClass.debugFunc) +3 >Emitted(6, 14) Source(6, 14) + SourceIndex(0) name (DebugClass.debugFunc) +4 >Emitted(6, 17) Source(6, 17) + SourceIndex(0) name (DebugClass.debugFunc) +5 >Emitted(6, 18) Source(6, 18) + SourceIndex(0) name (DebugClass.debugFunc) +6 >Emitted(6, 19) Source(6, 19) + SourceIndex(0) name (DebugClass.debugFunc) --- >>> i++; 1 >^^^^^^^^ @@ -239,18 +238,12 @@ sourceFile:sourceMapValidationWithComments.ts --- >>> // End Debugger Test Code 1->^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> - > // End Debugger Test Code - > - > > -2 > -3 > // End Debugger Test Code -1->Emitted(16, 9) Source(19, 9) + SourceIndex(0) name (DebugClass.debugFunc) -2 >Emitted(16, 9) Source(16, 9) + SourceIndex(0) name (DebugClass.debugFunc) -3 >Emitted(16, 34) Source(16, 34) + SourceIndex(0) name (DebugClass.debugFunc) +2 > // End Debugger Test Code +1->Emitted(16, 9) Source(16, 9) + SourceIndex(0) name (DebugClass.debugFunc) +2 >Emitted(16, 34) Source(16, 34) + SourceIndex(0) name (DebugClass.debugFunc) --- >>> return true; 1 >^^^^^^^^ diff --git a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.js.map b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.js.map index cc528f82334..d10b3f8f281 100644 --- a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.js.map +++ b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.js.map @@ -1,2 +1,2 @@ //// [fooResult.js.map] -{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["../testFiles/app.ts","../testFiles/app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,wIAAwI;;IACxIA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD;IAAAE;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file +{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["../testFiles/app.ts","../testFiles/app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAAA,gFAAgF;AAChF,wIAAwI;AACxI;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD;IAAAE;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.sourcemap.txt b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.sourcemap.txt index b26b7c71db6..fdc67bf563d 100644 --- a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.sourcemap.txt +++ b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNames.sourcemap.txt @@ -10,17 +10,12 @@ sourceFile:../testFiles/app.ts ------------------------------------------------------------------- >>>// Note in the out result we are using same folder name only different in casing 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >// Note in the out result we are using same folder name only different in casing - >// Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be just app.ts or app2.ts - > -2 > -3 >// Note in the out result we are using same folder name only different in casing -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >// Note in the out result we are using same folder name only different in casing +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) --- >>>// Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be just app.ts or app2.ts 1-> @@ -32,12 +27,17 @@ sourceFile:../testFiles/app.ts 2 >Emitted(2, 137) Source(2, 137) + SourceIndex(0) --- >>>var c = (function () { ->>> function c() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +--- +>>> function c() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.js.map b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.js.map index b27ad076cc8..5317cf7c306 100644 --- a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.js.map +++ b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.js.map @@ -1,3 +1,3 @@ //// [app.js.map] -{"version":3,"file":"app.js","sourceRoot":"","sources":["../testFiles/app.ts"],"names":["c","c.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,wIAAwI;;IACxIA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}//// [app2.js.map] +{"version":3,"file":"app.js","sourceRoot":"","sources":["../testFiles/app.ts"],"names":["c","c.constructor"],"mappings":"AAAA,gFAAgF;AAChF,wIAAwI;AACxI;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}//// [app2.js.map] {"version":3,"file":"app2.js","sourceRoot":"","sources":["../testFiles/app2.ts"],"names":["d","d.constructor"],"mappings":"AAAA;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.sourcemap.txt b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.sourcemap.txt index 6064ee003df..44dd1b41048 100644 --- a/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.sourcemap.txt +++ b/tests/baselines/reference/sourceMapWithCaseSensitiveFileNamesAndOutDir.sourcemap.txt @@ -10,17 +10,12 @@ sourceFile:../testFiles/app.ts ------------------------------------------------------------------- >>>// Note in the out result we are using same folder name only different in casing 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >// Note in the out result we are using same folder name only different in casing - >// Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be just app.ts or app2.ts - > -2 > -3 >// Note in the out result we are using same folder name only different in casing -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >// Note in the out result we are using same folder name only different in casing +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) --- >>>// Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be just app.ts or app2.ts 1-> @@ -32,12 +27,17 @@ sourceFile:../testFiles/app.ts 2 >Emitted(2, 137) Source(2, 137) + SourceIndex(0) --- >>>var c = (function () { ->>> function c() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +--- +>>> function c() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map index 59e28d92f90..5d866e941db 100644 --- a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map @@ -1,2 +1,2 @@ //// [a.js.map] -{"version":3,"file":"a.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AAAA;;6EAE6E;AAE7E,IAAI,CAAC,GAAG;IACJ,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;CACR,CAAC;ACPF;;6EAE6E;AAG7E,AADA,2BAA2B;IACvB,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"a.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AAAA;;6EAE6E;AAE7E,IAAI,CAAC,GAAG;IACJ,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;CACR,CAAC;ACPF;;6EAE6E;AAE7E,2BAA2B;AAC3B,IAAI,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt index 5a87f6c04e8..f3f3dffd9dc 100644 --- a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt @@ -100,35 +100,34 @@ sourceFile:tests/cases/compiler/b.ts --- >>>/// 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > > - >/// > -2 > -3 >/// -1 >Emitted(11, 1) Source(6, 1) + SourceIndex(1) -2 >Emitted(11, 1) Source(5, 1) + SourceIndex(1) -3 >Emitted(11, 28) Source(5, 28) + SourceIndex(1) +2 >/// +1 >Emitted(11, 1) Source(5, 1) + SourceIndex(1) +2 >Emitted(11, 28) Source(5, 28) + SourceIndex(1) --- >>>var y = x; -1 >^^^^ -2 > ^ -3 > ^^^ -4 > ^ -5 > ^ -6 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^^^^^^^^^^^^^-> 1 > - >var -2 > y -3 > = -4 > x -5 > ; -1 >Emitted(12, 5) Source(6, 5) + SourceIndex(1) -2 >Emitted(12, 6) Source(6, 6) + SourceIndex(1) -3 >Emitted(12, 9) Source(6, 9) + SourceIndex(1) -4 >Emitted(12, 10) Source(6, 10) + SourceIndex(1) -5 >Emitted(12, 11) Source(6, 11) + SourceIndex(1) + > +2 >var +3 > y +4 > = +5 > x +6 > ; +1 >Emitted(12, 1) Source(6, 1) + SourceIndex(1) +2 >Emitted(12, 5) Source(6, 5) + SourceIndex(1) +3 >Emitted(12, 6) Source(6, 6) + SourceIndex(1) +4 >Emitted(12, 9) Source(6, 9) + SourceIndex(1) +5 >Emitted(12, 10) Source(6, 10) + SourceIndex(1) +6 >Emitted(12, 11) Source(6, 11) + SourceIndex(1) --- >>>//# sourceMappingURL=a.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.js.map b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.js.map index e3262d8c686..200edeccc5b 100644 --- a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.js.map +++ b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.js.map @@ -1,2 +1,2 @@ //// [fooResult.js.map] -{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["app.ts","app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,0GAA0G;;IAC1GA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD;IAAAE;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file +{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["app.ts","app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAAA,gFAAgF;AAChF,0GAA0G;AAC1G;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD;IAAAE;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.sourcemap.txt b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.sourcemap.txt index 560fd29616d..790d64c7963 100644 --- a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.sourcemap.txt +++ b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNames.sourcemap.txt @@ -10,17 +10,12 @@ sourceFile:app.ts ------------------------------------------------------------------- >>>// Note in the out result we are using same folder name only different in casing 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >// Note in the out result we are using same folder name only different in casing - >// Since this is non case sensitive, the relative paths should be just app.ts and app2.ts in the sourcemap - > -2 > -3 >// Note in the out result we are using same folder name only different in casing -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >// Note in the out result we are using same folder name only different in casing +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) --- >>>// Since this is non case sensitive, the relative paths should be just app.ts and app2.ts in the sourcemap 1-> @@ -32,12 +27,17 @@ sourceFile:app.ts 2 >Emitted(2, 107) Source(2, 107) + SourceIndex(0) --- >>>var c = (function () { ->>> function c() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +--- +>>> function c() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.js.map b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.js.map index 9fff2ee3f66..97826d80eb8 100644 --- a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.js.map +++ b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.js.map @@ -1,3 +1,3 @@ //// [app.js.map] -{"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":["c","c.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,0GAA0G;;IAC1GA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}//// [app2.js.map] +{"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":["c","c.constructor"],"mappings":"AAAA,gFAAgF;AAChF,0GAA0G;AAC1G;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}//// [app2.js.map] {"version":3,"file":"app2.js","sourceRoot":"","sources":["app2.ts"],"names":["d","d.constructor"],"mappings":"AAAA;IAAAA;IACAC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.sourcemap.txt b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.sourcemap.txt index f91aaea6ab9..6987b7bbd21 100644 --- a/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.sourcemap.txt +++ b/tests/baselines/reference/sourceMapWithNonCaseSensitiveFileNamesAndOutDir.sourcemap.txt @@ -10,17 +10,12 @@ sourceFile:app.ts ------------------------------------------------------------------- >>>// Note in the out result we are using same folder name only different in casing 1 > -2 > -3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >// Note in the out result we are using same folder name only different in casing - >// Since this is non case sensitive, the relative paths should be just app.ts and app2.ts in the sourcemap - > -2 > -3 >// Note in the out result we are using same folder name only different in casing -1 >Emitted(1, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -3 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >// Note in the out result we are using same folder name only different in casing +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 81) Source(1, 81) + SourceIndex(0) --- >>>// Since this is non case sensitive, the relative paths should be just app.ts and app2.ts in the sourcemap 1-> @@ -32,12 +27,17 @@ sourceFile:app.ts 2 >Emitted(2, 107) Source(2, 107) + SourceIndex(0) --- >>>var c = (function () { ->>> function c() { -1 >^^^^ -2 > ^^-> +1 > +2 >^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +--- +>>> function c() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(4, 5) Source(3, 1) + SourceIndex(0) name (c) --- >>> } 1->^^^^ diff --git a/tests/baselines/reference/stringIncludes.symbols b/tests/baselines/reference/stringIncludes.symbols index d0fa641c857..0ca53dbb837 100644 --- a/tests/baselines/reference/stringIncludes.symbols +++ b/tests/baselines/reference/stringIncludes.symbols @@ -5,11 +5,11 @@ var includes: boolean; includes = "abcde".includes("cd"); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) includes = "abcde".includes("cd", 2); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4222, 37)) diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e6cba35be25..1f4ee3debed 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. - Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. + Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. +!!! error TS2322: Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index 13d5adcf1f5..faef7905453 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,11 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. Index signatures are incompatible. - Type 'typeof A | typeof B' is not assignable to type 'A'. - Type 'typeof A' is not assignable to type 'A'. - Property 'foo' is missing in type 'typeof A'. + Type 'typeof A' is not assignable to type 'A'. + Property 'foo' is missing in type 'typeof A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -61,11 +60,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: A } = { ~ -!!! error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'typeof A | typeof B' is not assignable to type 'A'. -!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'typeof A'. +!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. +!!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, b: B } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index eeedf58ab73..2bb0db83e6d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -101,12 +101,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,7): error TS2415: Class 'D23' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. + Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,7): error TS2415: Class 'D24' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'U'. + Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. @@ -441,6 +443,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D23' incorrectly extends base class 'C3'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'V' is not assignable to type 'T'. +!!! error TS2415: Type 'Date' is not assignable to type 'T'. ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ @@ -456,6 +459,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D24' incorrectly extends base class 'C3'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'V' is not assignable to type 'U'. +!!! error TS2415: Type 'Date' is not assignable to type 'U'. ~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index a9b025ccc77..7b3d706606d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(45,7): error TS2415: Class 'D3' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'Foo'. - Property 'foo' is missing in type '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(55,7): error TS2415: Class 'D5' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(60,7): error TS2415: Class 'D6' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. @@ -14,6 +14,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(65,7): error TS2415: Class 'D7' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(75,7): error TS2415: Class 'D9' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. @@ -71,7 +72,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D3' incorrectly extends base class 'B1'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'V' is not assignable to type 'Foo'. -!!! error TS2415: Property 'foo' is missing in type '{}'. [x: string]: Foo; foo: V; // error ~~~~~~~ @@ -88,6 +88,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D5' incorrectly extends base class 'B1'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'T'. +!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: U; // error ~~~~~~~ @@ -110,6 +111,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D7' incorrectly extends base class 'B1'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'T' is not assignable to type 'U'. +!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: T; // error ~~~~~~~ diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 867b622cf1a..22b8c3cfb35 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,11): error TS2415: Class 'D2' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -14,6 +15,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,11): error TS2415: Class 'D3' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -21,6 +23,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,11): error TS2415: Class 'D4' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -31,6 +34,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,11): error TS2415: Class 'D6' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -38,6 +42,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,11): error TS2415: Class 'D7' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -45,6 +50,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,11): error TS2415: Class 'D8' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -170,6 +176,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D2' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'T'. +!!! error TS2415: Type 'Foo' is not assignable to type 'T'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ @@ -187,6 +194,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D3' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'V' is not assignable to type 'T'. +!!! error TS2415: Type 'Foo' is not assignable to type 'T'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ @@ -204,6 +212,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D4' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'T' is not assignable to type 'U'. +!!! error TS2415: Type 'Foo' is not assignable to type 'U'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ @@ -232,6 +241,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D6' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'V' is not assignable to type 'U'. +!!! error TS2415: Type 'Foo' is not assignable to type 'U'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ @@ -249,6 +259,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D7' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'T' is not assignable to type 'V'. +!!! error TS2415: Type 'Foo' is not assignable to type 'V'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ @@ -266,6 +277,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2415: Class 'D8' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'foo' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'V'. +!!! error TS2415: Type 'Foo' is not assignable to type 'V'. ~~~~~~~~~~~~~~~~ !!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index e43382766ac..b72993e7bea 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -331,14 +331,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : (((x: number) => number[]) | ((x: T) => T[]))[] ->[r1arg2, r1arg1] : (((x: number) => number[]) | ((x: T) => T[]))[] +>r1a : ((x: T) => T[])[] +>[r1arg2, r1arg1] : ((x: T) => T[])[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : (((x: T) => T[]) | ((x: number) => number[]))[] ->[r1arg1, r1arg2] : (((x: T) => T[]) | ((x: number) => number[]))[] +>r1b : ((x: T) => T[])[] +>[r1arg1, r1arg2] : ((x: T) => T[])[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -365,14 +365,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : (((x: T) => string[]) | ((x: number) => string[]))[] ->[r2arg1, r2arg2] : (((x: T) => string[]) | ((x: number) => string[]))[] +>r2a : ((x: T) => string[])[] +>[r2arg1, r2arg2] : ((x: T) => string[])[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : (((x: number) => string[]) | ((x: T) => string[]))[] ->[r2arg2, r2arg1] : (((x: number) => string[]) | ((x: T) => string[]))[] +>r2b : ((x: number) => string[])[] +>[r2arg2, r2arg1] : ((x: number) => string[])[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -396,14 +396,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : (((x: T) => T) | ((x: number) => void))[] ->[r3arg1, r3arg2] : (((x: T) => T) | ((x: number) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg1, r3arg2] : ((x: T) => T)[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : (((x: number) => void) | ((x: T) => T))[] ->[r3arg2, r3arg1] : (((x: number) => void) | ((x: T) => T))[] +>r3b : ((x: number) => void)[] +>[r3arg2, r3arg1] : ((x: number) => void)[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -432,14 +432,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] ->[r4arg1, r4arg2] : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] +>r4a : ((x: T, y: U) => T)[] +>[r4arg1, r4arg2] : ((x: T, y: U) => T)[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] ->[r4arg2, r4arg1] : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] +>r4b : ((x: T, y: U) => T)[] +>[r4arg2, r4arg1] : ((x: T, y: U) => T)[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] ->[r7arg2, r7arg1] : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] ->[r8arg2, r8arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] ->[r9arg2, r9arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -719,14 +719,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] +>r10a : ((...x: T[]) => T)[] +>[r10arg1, r10arg2] : ((...x: T[]) => T)[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] ->[r10arg2, r10arg1] : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] +>r10b : ((...x: T[]) => T)[] +>[r10arg2, r10arg1] : ((...x: T[]) => T)[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -760,14 +760,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : ((x: T, y: T) => T)[] +>[r11arg1, r11arg2] : ((x: T, y: T) => T)[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r11arg2, r11arg1] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r11b : ((x: T, y: T) => T)[] +>[r11arg2, r11arg1] : ((x: T, y: T) => T)[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -808,14 +808,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : ((x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] +>r12b : ((x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : ((x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -853,14 +853,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] +>r13a : ((x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] +>r13b : ((x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -894,14 +894,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>r14a : ((x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] +>r14b : ((x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 0d3a84ac99c..2d4c6e9fda5 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -219,8 +219,8 @@ module Errors { >null : null var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : (((x: number) => string[]) | ((x: T) => U[]))[] ->[(x: number) => [''], (x: T) => null] : (((x: number) => string[]) | ((x: T) => U[]))[] +>r1a : ((x: T) => U[])[] +>[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -235,8 +235,8 @@ module Errors { >null : null var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : (((x: T) => U[]) | ((x: number) => string[]))[] ->[(x: T) => null, (x: number) => ['']] : (((x: T) => U[]) | ((x: number) => string[]))[] +>r1b : ((x: T) => U[])[] +>[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] ->[r2arg2, r2arg] : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -387,14 +387,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] ->[r4arg2, r4arg] : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] +>r4a : ((...x: T[]) => T)[] +>[r4arg2, r4arg] : ((...x: T[]) => T)[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] ->[r4arg, r4arg2] : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] +>r4b : ((...x: T[]) => T)[] +>[r4arg, r4arg2] : ((...x: T[]) => T)[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -430,14 +430,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r5arg2, r5arg] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r5a : ((x: T, y: T) => T)[] +>[r5arg2, r5arg] : ((x: T, y: T) => T)[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg, r5arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : ((x: T, y: T) => T)[] +>[r5arg, r5arg2] : ((x: T, y: T) => T)[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -478,14 +478,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg] : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : ((x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] ->[r6arg, r6arg2] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] +>r6b : ((x: Base[], y: Base[]) => T)[] +>[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -517,14 +517,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] +>r7a : ((x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] ->[r7arg, r7arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] +>r7b : ((x: { a: T; b: T; }) => T)[] +>[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -547,14 +547,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] +>r7d : ((x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] +>r7e : ((x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : ((x: { a: T; b: T; }) => number)[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 830f065f556..f490f787878 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -317,14 +317,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : (((x: T) => T) | ((x: T) => void))[] ->[r3arg, r3arg2] : (((x: T) => T) | ((x: T) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg, r3arg2] : ((x: T) => T)[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : (((x: T) => void) | ((x: T) => T))[] ->[r3arg2, r3arg] : (((x: T) => void) | ((x: T) => T))[] +>r3b : ((x: T) => void)[] +>[r3arg2, r3arg] : ((x: T) => void)[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg] : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -498,14 +498,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -543,14 +543,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] +>r15a : ((x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] +>r15b : ((x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : ((x: { a: T; b: T; }) => T[])[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index f00ad0332ca..c66d6055558 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : ((new (x: number) => number[]) | (new (x: T) => T[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => number[]) | (new (x: T) => T[]))[] +>r1a : (new (x: T) => T[])[] +>[r1arg2, r1arg1] : (new (x: T) => T[])[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : ((new (x: T) => T[]) | (new (x: number) => number[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => T[]) | (new (x: number) => number[]))[] +>r1b : (new (x: T) => T[])[] +>[r1arg1, r1arg2] : (new (x: T) => T[])[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : ((new (x: T) => string[]) | (new (x: number) => string[]))[] ->[r2arg1, r2arg2] : ((new (x: T) => string[]) | (new (x: number) => string[]))[] +>r2a : (new (x: T) => string[])[] +>[r2arg1, r2arg2] : (new (x: T) => string[])[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : ((new (x: number) => string[]) | (new (x: T) => string[]))[] ->[r2arg2, r2arg1] : ((new (x: number) => string[]) | (new (x: T) => string[]))[] +>r2b : (new (x: number) => string[])[] +>[r2arg2, r2arg1] : (new (x: number) => string[])[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: number) => void))[] ->[r3arg1, r3arg2] : ((new (x: T) => T) | (new (x: number) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg1, r3arg2] : (new (x: T) => T)[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : ((new (x: number) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg1] : ((new (x: number) => void) | (new (x: T) => T))[] +>r3b : (new (x: number) => void)[] +>[r3arg2, r3arg1] : (new (x: number) => void)[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] ->[r4arg1, r4arg2] : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] +>r4a : (new (x: T, y: U) => T)[] +>[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] ->[r4arg2, r4arg1] : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] +>r4b : (new (x: T, y: U) => T)[] +>[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] ->[r7arg1, r7arg2] : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] +>r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] ->[r7arg2, r7arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] +>r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r8arg1, r8arg2] : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] ->[r8arg2, r8arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] +>r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] +>r10a : (new (...x: T[]) => T)[] +>[r10arg1, r10arg2] : (new (...x: T[]) => T)[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] ->[r10arg2, r10arg1] : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] +>r10b : (new (...x: T[]) => T)[] +>[r10arg2, r10arg1] : (new (...x: T[]) => T)[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : (new (x: T, y: T) => T)[] +>[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r11arg2, r11arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r11b : (new (x: T, y: T) => T)[] +>[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : (new (x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] +>r12b : (new (x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : (new (x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] +>r13a : (new (x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] +>r13b : (new (x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>r14a : (new (x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] +>r14b : (new (x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index b7c90d8697e..741db4f4ba6 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : ((new (x: number) => string[]) | (new (x: T) => U[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => string[]) | (new (x: T) => U[]))[] +>r1a : (new (x: T) => U[])[] +>[r1arg2, r1arg1] : (new (x: T) => U[])[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : ((new (x: T) => U[]) | (new (x: number) => string[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => U[]) | (new (x: number) => string[]))[] +>r1b : (new (x: T) => U[])[] +>[r1arg1, r1arg2] : (new (x: T) => U[])[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] ->[r2arg2, r2arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] +>r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] ->[r2arg1, r2arg2] : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] +>r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] ->[r4arg2, r4arg1] : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] +>r4a : (new (...x: T[]) => T)[] +>[r4arg2, r4arg1] : (new (...x: T[]) => T)[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] ->[r4arg1, r4arg2] : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] +>r4b : (new (...x: T[]) => T)[] +>[r4arg1, r4arg2] : (new (...x: T[]) => T)[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r5arg2, r5arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r5a : (new (x: T, y: T) => T)[] +>[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg1, r5arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : (new (x: T, y: T) => T)[] +>[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg1] : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : (new (x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] ->[r6arg1, r6arg2] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] +>r6b : (new (x: Base[], y: Base[]) => T)[] +>[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg1] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] +>r7a : (new (x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg1, r7arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] +>r7b : (new (x: { a: T; b: T; }) => T)[] +>[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] +>r7d : (new (x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] +>r7e : (new (x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : (new (x: { a: T; b: T; }) => number)[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 328dadad41c..932adcb7368 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: T) => void))[] ->[r3arg, r3arg2] : ((new (x: T) => T) | (new (x: T) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg, r3arg2] : (new (x: T) => T)[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : ((new (x: T) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg] : ((new (x: T) => void) | (new (x: T) => T))[] +>r3b : (new (x: T) => void)[] +>[r3arg2, r3arg] : (new (x: T) => void)[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg] : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : (new (x: new (arg: T) => Derived) => T)[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] +>r15a : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] +>r15b : (new (x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : (new (x: { a: T; b: T; }) => T[])[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 0d55d78e266..815f2d60740 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -85,8 +85,8 @@ var b = { Foo: null }; >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -156,8 +156,8 @@ module TwoLevels { >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived2; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived2; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived2; } diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index a6b698413ec..1d060672ceb 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -79,7 +79,7 @@ var Base2 = (function () { function Base2() { } Base2.prototype.foo = function () { - _super.foo.call(this); + _super.prototype.foo.call(this); }; return Base2; })(); diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index 6a52cfcd9e7..5c2182d8afb 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -165,7 +165,7 @@ var Base4; function Sub4E() { } Sub4E.prototype.x = function () { - return _super.x.call(this); + return _super.prototype.x.call(this); }; return Sub4E; })(); diff --git a/tests/baselines/reference/superCallInsideClassDeclaration.errors.txt b/tests/baselines/reference/superCallInsideClassDeclaration.errors.txt new file mode 100644 index 00000000000..ddb877f3f4e --- /dev/null +++ b/tests/baselines/reference/superCallInsideClassDeclaration.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/superCallInsideClassDeclaration.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. + + +==== tests/cases/compiler/superCallInsideClassDeclaration.ts (1 errors) ==== + class A { + } + + class C { + } + + class B extends A { + constructor() { + ~~~~~~~~~~~~~~~ + + + class D extends C { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + constructor() { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~~~~~~~~~ + } + ~~~~~~~~~ + } + ~~~~~ +!!! error TS2377: Constructors for derived classes must contain a 'super' call. + } \ No newline at end of file diff --git a/tests/baselines/reference/superCallInsideClassDeclaration.js b/tests/baselines/reference/superCallInsideClassDeclaration.js new file mode 100644 index 00000000000..6d16aceb247 --- /dev/null +++ b/tests/baselines/reference/superCallInsideClassDeclaration.js @@ -0,0 +1,47 @@ +//// [superCallInsideClassDeclaration.ts] +class A { +} + +class C { +} + +class B extends A { + constructor() { + + class D extends C { + constructor() { + super(); + } + } + } +} + +//// [superCallInsideClassDeclaration.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + return C; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + var D = (function (_super) { + __extends(D, _super); + function D() { + _super.call(this); + } + return D; + })(C); + } + return B; +})(A); diff --git a/tests/baselines/reference/superCallInsideClassExpression.errors.txt b/tests/baselines/reference/superCallInsideClassExpression.errors.txt new file mode 100644 index 00000000000..736f31c4d0f --- /dev/null +++ b/tests/baselines/reference/superCallInsideClassExpression.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/superCallInsideClassExpression.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. + + +==== tests/cases/compiler/superCallInsideClassExpression.ts (1 errors) ==== + class A { + } + + class C { + } + + class B extends A { + constructor() { + ~~~~~~~~~~~~~~~ + + + var D = class extends C { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + constructor() { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~~~~~~~~~ + } + ~~~~~~~~~ + } + ~~~~~ +!!! error TS2377: Constructors for derived classes must contain a 'super' call. + } \ No newline at end of file diff --git a/tests/baselines/reference/superCallInsideClassExpression.js b/tests/baselines/reference/superCallInsideClassExpression.js new file mode 100644 index 00000000000..ea24003d9b7 --- /dev/null +++ b/tests/baselines/reference/superCallInsideClassExpression.js @@ -0,0 +1,47 @@ +//// [superCallInsideClassExpression.ts] +class A { +} + +class C { +} + +class B extends A { + constructor() { + + var D = class extends C { + constructor() { + super(); + } + } + } +} + +//// [superCallInsideClassExpression.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + return C; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + var D = (function (_super) { + __extends(class_1, _super); + function class_1() { + _super.call(this); + } + return class_1; + })(C); + } + return B; +})(A); diff --git a/tests/baselines/reference/superCallInsideObjectLiteralExpression.js b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js new file mode 100644 index 00000000000..60513cf43ee --- /dev/null +++ b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js @@ -0,0 +1,36 @@ +//// [superCallInsideObjectLiteralExpression.ts] +class A { + foo() { + } +} + +class B extends A { + constructor() { + var x = { + x: super() + } + } +} + +//// [superCallInsideObjectLiteralExpression.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + A.prototype.foo = function () { + }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + var x = { + x: _super.call(this) + }; + } + return B; +})(A); diff --git a/tests/baselines/reference/superCallInsideObjectLiteralExpression.symbols b/tests/baselines/reference/superCallInsideObjectLiteralExpression.symbols new file mode 100644 index 00000000000..d01899ecfef --- /dev/null +++ b/tests/baselines/reference/superCallInsideObjectLiteralExpression.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/superCallInsideObjectLiteralExpression.ts === +class A { +>A : Symbol(A, Decl(superCallInsideObjectLiteralExpression.ts, 0, 0)) + + foo() { +>foo : Symbol(foo, Decl(superCallInsideObjectLiteralExpression.ts, 0, 9)) + } +} + +class B extends A { +>B : Symbol(B, Decl(superCallInsideObjectLiteralExpression.ts, 3, 1)) +>A : Symbol(A, Decl(superCallInsideObjectLiteralExpression.ts, 0, 0)) + + constructor() { + var x = { +>x : Symbol(x, Decl(superCallInsideObjectLiteralExpression.ts, 7, 11)) + + x: super() +>x : Symbol(x, Decl(superCallInsideObjectLiteralExpression.ts, 7, 17)) +>super : Symbol(A, Decl(superCallInsideObjectLiteralExpression.ts, 0, 0)) + } + } +} diff --git a/tests/baselines/reference/superCallInsideObjectLiteralExpression.types b/tests/baselines/reference/superCallInsideObjectLiteralExpression.types new file mode 100644 index 00000000000..6cbb8d3ae56 --- /dev/null +++ b/tests/baselines/reference/superCallInsideObjectLiteralExpression.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/superCallInsideObjectLiteralExpression.ts === +class A { +>A : A + + foo() { +>foo : () => void + } +} + +class B extends A { +>B : B +>A : A + + constructor() { + var x = { +>x : { x: void; } +>{ x: super() } : { x: void; } + + x: super() +>x : void +>super() : void +>super : typeof A + } + } +} diff --git a/tests/baselines/reference/superCallWithMissingBaseClass.errors.txt b/tests/baselines/reference/superCallWithMissingBaseClass.errors.txt new file mode 100644 index 00000000000..0f4e4b7dd13 --- /dev/null +++ b/tests/baselines/reference/superCallWithMissingBaseClass.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/superCallWithMissingBaseClass.ts(1,19): error TS2304: Cannot find name 'Bar'. + + +==== tests/cases/compiler/superCallWithMissingBaseClass.ts (1 errors) ==== + class Foo extends Bar { + ~~~ +!!! error TS2304: Cannot find name 'Bar'. + m1() { + return super.m1(); + } + + static m2() { + return super.m2(); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/superCallWithMissingBaseClass.js b/tests/baselines/reference/superCallWithMissingBaseClass.js new file mode 100644 index 00000000000..101e709653e --- /dev/null +++ b/tests/baselines/reference/superCallWithMissingBaseClass.js @@ -0,0 +1,30 @@ +//// [superCallWithMissingBaseClass.ts] +class Foo extends Bar { + m1() { + return super.m1(); + } + + static m2() { + return super.m2(); + } +} + +//// [superCallWithMissingBaseClass.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo() { + _super.apply(this, arguments); + } + Foo.prototype.m1 = function () { + return _super.prototype.m1.call(this); + }; + Foo.m2 = function () { + return _super.m2.call(this); + }; + return Foo; +})(Bar); diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.symbols b/tests/baselines/reference/superSymbolIndexedAccess1.symbols index 818d0ac52af..416ac465e24 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess1.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess1.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts === var symbol = Symbol.for('myThing'); >symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.symbols b/tests/baselines/reference/superSymbolIndexedAccess2.symbols index 3865b920647..726abb3fdc5 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess2.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess2.symbols @@ -4,9 +4,9 @@ class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return 0; } @@ -17,14 +17,14 @@ class Bar extends Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return super[Symbol.isConcatSpreadable](); >super : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } } diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 9fae9d57c4f..9a7d93c7246 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 5dba2268d26..63602f4fd2c 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index a6019a364e4..850bde66c49 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index e16ec738489..accb92a8c52 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index b2f520351f2..91a5cfdd760 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 7e9d06cd332..1993e369aea 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index 177180b5bca..84f39f363f1 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index 98cb277ad47..655a91fc88b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 17bda345253..1436f9b9f69 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index c4b046cc146..f07ebd532fa 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 58a661412da..0435dc15df2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 7879d28b02f..7e95754b1eb 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index 17901fb713a..d4f08115a21 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index 4028da455a6..3db0f7012cb 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 07e9b6bae26..62ce887a731 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index d4e79a064a9..c48bd271c87 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 2a83145da03..56f722c523b 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index 1b4b23e9511..092d766034e 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index 89df72d6543..b5d930b4005 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index 3ee9ed595c2..eae891f2e22 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index b52c4087d71..d03ca9a4c51 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index ad4f0c79523..110067abda5 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index b62037e32a5..2288537456c 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index da9d07ffeed..152048a95a8 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 46babb69a87..7a2e443368f 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 69fe473e17c..306802cdff2 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index cf6ab1f5edb..77b476c6ea3 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 4e17e561bce..c159cc756d8 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index e3e469764a8..29b66c96f1f 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 622d1b693e8..129c856b804 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 5aba3b8c104..34bb5ad967f 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index 7b57003e607..063ae8d3d34 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 4beb1f6d9e2..64472f3c71a 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 32240efd986..45a56260828 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index 05eeace3b86..98f4a7769b2 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 3850, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index a4e335cc7d7..fe73fb9f330 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 249545872b1..eaf5be2a07c 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 78be14d0862..04b89f43652 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 64452f49c9c..541833d686a 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index d40e0e72724..bbccd2a0f8b 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index a7de59a11b7..b251db43301 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -33,7 +33,7 @@ s || 1; >1 : number ({}) || s; ->({}) || s : {} | symbol +>({}) || s : {} >({}) : {} >{} : {} >s : symbol diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 4b61749b898..9a25d9ad152 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/systemModule10.js b/tests/baselines/reference/systemModule10.js index c63b3589085..fcecfc9b0f8 100644 --- a/tests/baselines/reference/systemModule10.js +++ b/tests/baselines/reference/systemModule10.js @@ -14,19 +14,19 @@ System.register(['file1', 'file2'], function(exports_1) { var file1_1, n2; return { setters:[ - function (_file1_1) { - file1_1 = _file1_1; - exports_1("n", file1_1["default"]); - exports_1("n1", file1_1["default"]); - exports_1("x", file1_1.x); - exports_1("y", file1_1.x); + function (file1_1_1) { + file1_1 = file1_1_1; }, - function (_n2) { - n2 = _n2; - exports_1("n2", n2); - exports_1("n3", n2); + function (n2_1) { + n2 = n2_1; }], execute: function() { + exports_1("x", file1_1.x); + exports_1("y", file1_1.x); + exports_1("n", file1_1["default"]); + exports_1("n1", file1_1["default"]); + exports_1("n2", n2); + exports_1("n3", n2); } } }); diff --git a/tests/baselines/reference/systemModule10_ES5.js b/tests/baselines/reference/systemModule10_ES5.js index bdb920414de..a86088a3463 100644 --- a/tests/baselines/reference/systemModule10_ES5.js +++ b/tests/baselines/reference/systemModule10_ES5.js @@ -14,19 +14,19 @@ System.register(['file1', 'file2'], function(exports_1) { var file1_1, n2; return { setters:[ - function (_file1_1) { - file1_1 = _file1_1; - exports_1("n", file1_1.default); - exports_1("n1", file1_1.default); - exports_1("x", file1_1.x); - exports_1("y", file1_1.x); + function (file1_1_1) { + file1_1 = file1_1_1; }, - function (_n2) { - n2 = _n2; - exports_1("n2", n2); - exports_1("n3", n2); + function (n2_1) { + n2 = n2_1; }], execute: function() { + exports_1("x", file1_1.x); + exports_1("y", file1_1.x); + exports_1("n", file1_1.default); + exports_1("n1", file1_1.default); + exports_1("n2", n2); + exports_1("n3", n2); } } }); diff --git a/tests/baselines/reference/systemModule11.js b/tests/baselines/reference/systemModule11.js index 34dd0d3df5f..bf9b57c511c 100644 --- a/tests/baselines/reference/systemModule11.js +++ b/tests/baselines/reference/systemModule11.js @@ -59,8 +59,8 @@ System.register(['bar'], function(exports_1) { } return { setters:[ - function (_bar_1) { - exportStar_1(_bar_1); + function (bar_1_1) { + exportStar_1(bar_1_1); }], execute: function() { } @@ -82,8 +82,8 @@ System.register(['bar'], function(exports_1) { } return { setters:[ - function (_bar_1) { - exportStar_1(_bar_1); + function (bar_1_1) { + exportStar_1(bar_1_1); }], execute: function() { exports_1("x", x); @@ -108,14 +108,14 @@ System.register(['a', 'bar'], function(exports_1) { } return { setters:[ - function (_a_1) { - var reexports_1 = {}; - reexports_1["x"] = _a_1["x"]; - reexports_1["z"] = _a_1["y"]; - exports_1(reexports_1); + function (a_1_1) { + exports_1({ + "x": a_1_1["x"], + "z": a_1_1["y"] + }); }, - function (_bar_1) { - exportStar_1(_bar_1); + function (bar_1_1) { + exportStar_1(bar_1_1); }], execute: function() { } @@ -130,11 +130,11 @@ System.register(['a'], function(exports_1) { exports_1("default", default_1); return { setters:[ - function (_a_1) { - var reexports_1 = {}; - reexports_1["s"] = _a_1["s"]; - reexports_1["s2"] = _a_1["s1"]; - exports_1(reexports_1); + function (a_1_1) { + exports_1({ + "s": a_1_1["s"], + "s2": a_1_1["s1"] + }); }], execute: function() { exports_1("z", z); @@ -154,8 +154,8 @@ System.register(['a'], function(exports_1) { } return { setters:[ - function (_a_1) { - exportStar_1(_a_1); + function (a_1_1) { + exportStar_1(a_1_1); }], execute: function() { } diff --git a/tests/baselines/reference/systemModule14.errors.txt b/tests/baselines/reference/systemModule14.errors.txt new file mode 100644 index 00000000000..6ba64896df8 --- /dev/null +++ b/tests/baselines/reference/systemModule14.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/systemModule14.ts(6,17): error TS2307: Cannot find module 'foo'. + + +==== tests/cases/compiler/systemModule14.ts (1 errors) ==== + + function foo() { + return a; + } + + import {a} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + export {foo} + + var x = 1; + export {foo as b} \ No newline at end of file diff --git a/tests/baselines/reference/systemModule14.js b/tests/baselines/reference/systemModule14.js new file mode 100644 index 00000000000..76906db5980 --- /dev/null +++ b/tests/baselines/reference/systemModule14.js @@ -0,0 +1,31 @@ +//// [systemModule14.ts] + +function foo() { + return a; +} + +import {a} from "foo"; +export {foo} + +var x = 1; +export {foo as b} + +//// [systemModule14.js] +System.register(["foo"], function(exports_1) { + var foo_1; + var x; + function foo() { + return foo_1.a; + } + return { + setters:[ + function (foo_1_1) { + foo_1 = foo_1_1; + }], + execute: function() { + exports_1("foo", foo); + x = 1; + exports_1("b", foo); + } + } +}); diff --git a/tests/baselines/reference/systemModule15.js b/tests/baselines/reference/systemModule15.js new file mode 100644 index 00000000000..4d5536cbaa1 --- /dev/null +++ b/tests/baselines/reference/systemModule15.js @@ -0,0 +1,88 @@ +//// [tests/cases/compiler/systemModule15.ts] //// + +//// [file1.ts] + + +import * as moduleB from "./file2" + +declare function use(v: any): void; + +use(moduleB.value); +use(moduleB.moduleC); +use(moduleB.moduleCStar); + +//// [file2.ts] + +import * as moduleCStar from "./file3" +import {value2} from "./file4" +import moduleC from "./file3" +import {value} from "./file3" + +export { + moduleCStar, + moduleC, + value +} + +//// [file3.ts] + +export var value = "youpi"; +export default value; + +//// [file4.ts] + +export var value2 = "v"; + +//// [file3.js] +System.register([], function(exports_1) { + var value; + return { + setters:[], + execute: function() { + exports_1("value", value = "youpi"); + exports_1("default",value); + } + } +}); +//// [file4.js] +System.register([], function(exports_1) { + var value2; + return { + setters:[], + execute: function() { + exports_1("value2", value2 = "v"); + } + } +}); +//// [file2.js] +System.register(["./file3"], function(exports_1) { + var moduleCStar, file3_1, file3_2; + return { + setters:[ + function (moduleCStar_1) { + moduleCStar = moduleCStar_1; + file3_1 = moduleCStar_1; + file3_2 = moduleCStar_1; + }], + execute: function() { + exports_1("moduleCStar", moduleCStar); + exports_1("moduleC", file3_1["default"]); + exports_1("value", file3_2.value); + } + } +}); +//// [file1.js] +System.register(["./file2"], function(exports_1) { + var moduleB; + return { + setters:[ + function (moduleB_1) { + moduleB = moduleB_1; + }], + execute: function() { + use(moduleB.value); + use(moduleB.moduleC); + use(moduleB.moduleCStar); + } + } +}); diff --git a/tests/baselines/reference/systemModule15.symbols b/tests/baselines/reference/systemModule15.symbols new file mode 100644 index 00000000000..2572950a7f2 --- /dev/null +++ b/tests/baselines/reference/systemModule15.symbols @@ -0,0 +1,66 @@ +=== tests/cases/compiler/file1.ts === + + +import * as moduleB from "./file2" +>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6)) + +declare function use(v: any): void; +>use : Symbol(use, Decl(file1.ts, 2, 34)) +>v : Symbol(v, Decl(file1.ts, 4, 21)) + +use(moduleB.value); +>use : Symbol(use, Decl(file1.ts, 2, 34)) +>moduleB.value : Symbol(moduleB.value, Decl(file2.ts, 8, 12)) +>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6)) +>value : Symbol(moduleB.value, Decl(file2.ts, 8, 12)) + +use(moduleB.moduleC); +>use : Symbol(use, Decl(file1.ts, 2, 34)) +>moduleB.moduleC : Symbol(moduleB.moduleC, Decl(file2.ts, 7, 16)) +>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6)) +>moduleC : Symbol(moduleB.moduleC, Decl(file2.ts, 7, 16)) + +use(moduleB.moduleCStar); +>use : Symbol(use, Decl(file1.ts, 2, 34)) +>moduleB.moduleCStar : Symbol(moduleB.moduleCStar, Decl(file2.ts, 6, 8)) +>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6)) +>moduleCStar : Symbol(moduleB.moduleCStar, Decl(file2.ts, 6, 8)) + +=== tests/cases/compiler/file2.ts === + +import * as moduleCStar from "./file3" +>moduleCStar : Symbol(moduleCStar, Decl(file2.ts, 1, 6)) + +import {value2} from "./file4" +>value2 : Symbol(value2, Decl(file2.ts, 2, 8)) + +import moduleC from "./file3" +>moduleC : Symbol(moduleC, Decl(file2.ts, 3, 6)) + +import {value} from "./file3" +>value : Symbol(value, Decl(file2.ts, 4, 8)) + +export { + moduleCStar, +>moduleCStar : Symbol(moduleCStar, Decl(file2.ts, 6, 8)) + + moduleC, +>moduleC : Symbol(moduleC, Decl(file2.ts, 7, 16)) + + value +>value : Symbol(value, Decl(file2.ts, 8, 12)) +} + +=== tests/cases/compiler/file3.ts === + +export var value = "youpi"; +>value : Symbol(value, Decl(file3.ts, 1, 10)) + +export default value; +>value : Symbol(value, Decl(file3.ts, 1, 10)) + +=== tests/cases/compiler/file4.ts === + +export var value2 = "v"; +>value2 : Symbol(value2, Decl(file4.ts, 1, 10)) + diff --git a/tests/baselines/reference/systemModule15.types b/tests/baselines/reference/systemModule15.types new file mode 100644 index 00000000000..502638dab93 --- /dev/null +++ b/tests/baselines/reference/systemModule15.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/file1.ts === + + +import * as moduleB from "./file2" +>moduleB : typeof moduleB + +declare function use(v: any): void; +>use : (v: any) => void +>v : any + +use(moduleB.value); +>use(moduleB.value) : void +>use : (v: any) => void +>moduleB.value : string +>moduleB : typeof moduleB +>value : string + +use(moduleB.moduleC); +>use(moduleB.moduleC) : void +>use : (v: any) => void +>moduleB.moduleC : string +>moduleB : typeof moduleB +>moduleC : string + +use(moduleB.moduleCStar); +>use(moduleB.moduleCStar) : void +>use : (v: any) => void +>moduleB.moduleCStar : typeof +>moduleB : typeof moduleB +>moduleCStar : typeof + +=== tests/cases/compiler/file2.ts === + +import * as moduleCStar from "./file3" +>moduleCStar : typeof moduleCStar + +import {value2} from "./file4" +>value2 : string + +import moduleC from "./file3" +>moduleC : string + +import {value} from "./file3" +>value : string + +export { + moduleCStar, +>moduleCStar : typeof moduleCStar + + moduleC, +>moduleC : string + + value +>value : string +} + +=== tests/cases/compiler/file3.ts === + +export var value = "youpi"; +>value : string +>"youpi" : string + +export default value; +>value : string + +=== tests/cases/compiler/file4.ts === + +export var value2 = "v"; +>value2 : string +>"v" : string + diff --git a/tests/baselines/reference/systemModule16.errors.txt b/tests/baselines/reference/systemModule16.errors.txt new file mode 100644 index 00000000000..8c79c9218e4 --- /dev/null +++ b/tests/baselines/reference/systemModule16.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/systemModule16.ts(2,20): error TS2307: Cannot find module 'foo'. +tests/cases/compiler/systemModule16.ts(3,20): error TS2307: Cannot find module 'bar'. +tests/cases/compiler/systemModule16.ts(4,15): error TS2307: Cannot find module 'foo'. +tests/cases/compiler/systemModule16.ts(5,15): error TS2307: Cannot find module 'bar'. +tests/cases/compiler/systemModule16.ts(8,32): error TS2307: Cannot find module 'foo'. +tests/cases/compiler/systemModule16.ts(9,32): error TS2307: Cannot find module 'bar'. + + +==== tests/cases/compiler/systemModule16.ts (6 errors) ==== + + import * as x from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + import * as y from "bar"; + ~~~~~ +!!! error TS2307: Cannot find module 'bar'. + export * from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + export * from "bar" + ~~~~~ +!!! error TS2307: Cannot find module 'bar'. + export {x} + export {y} + import {a1, b1, c1 as d1} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + export {a2, b2, c2 as d2} from "bar"; + ~~~~~ +!!! error TS2307: Cannot find module 'bar'. + + x,y,a1,b1,d1; + \ No newline at end of file diff --git a/tests/baselines/reference/systemModule16.js b/tests/baselines/reference/systemModule16.js new file mode 100644 index 00000000000..851b941492a --- /dev/null +++ b/tests/baselines/reference/systemModule16.js @@ -0,0 +1,54 @@ +//// [systemModule16.ts] + +import * as x from "foo"; +import * as y from "bar"; +export * from "foo"; +export * from "bar" +export {x} +export {y} +import {a1, b1, c1 as d1} from "foo"; +export {a2, b2, c2 as d2} from "bar"; + +x,y,a1,b1,d1; + + +//// [systemModule16.js] +System.register(["foo", "bar"], function(exports_1) { + var x, y, foo_1; + var exportedNames_1 = { + 'x': true, + 'y': true, + 'a2': true, + 'b2': true, + 'd2': true + }; + function exportStar_1(m) { + var exports = {}; + for(var n in m) { + if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; + } + exports_1(exports); + } + return { + setters:[ + function (x_1) { + x = x_1; + exportStar_1(x_1); + foo_1 = x_1; + }, + function (y_1) { + y = y_1; + exportStar_1(y_1); + exports_1({ + "a2": y_1["a2"], + "b2": y_1["b2"], + "d2": y_1["c2"] + }); + }], + execute: function() { + exports_1("x", x); + exports_1("y", y); + x, y, foo_1.a1, foo_1.b1, foo_1.c1; + } + } +}); diff --git a/tests/baselines/reference/systemModule9.js b/tests/baselines/reference/systemModule9.js index c282a47b686..d7913f2f8b7 100644 --- a/tests/baselines/reference/systemModule9.js +++ b/tests/baselines/reference/systemModule9.js @@ -38,24 +38,24 @@ System.register(['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7'], } return { setters:[ - function (_ns) { - ns = _ns; + function (ns_1) { + ns = ns_1; }, - function (_file2_1) { - file2_1 = _file2_1; + function (file2_1_1) { + file2_1 = file2_1_1; }, - function (_file3_1) { - file3_1 = _file3_1; + function (file3_1_1) { + file3_1 = file3_1_1; }, - function (_) {}, - function (_file5_1) { - file5_1 = _file5_1; + function (_1) {}, + function (file5_1_1) { + file5_1 = file5_1_1; }, - function (_ns3) { - ns3 = _ns3; + function (ns3_1) { + ns3 = ns3_1; }, - function (_file7_1) { - exportStar_1(_file7_1); + function (file7_1_1) { + exportStar_1(file7_1_1); }], execute: function() { ns.f(); diff --git a/tests/baselines/reference/systemModuleWithSuperClass.js b/tests/baselines/reference/systemModuleWithSuperClass.js new file mode 100644 index 00000000000..9d1e87fbc66 --- /dev/null +++ b/tests/baselines/reference/systemModuleWithSuperClass.js @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/systemModuleWithSuperClass.ts] //// + +//// [foo.ts] + +export class Foo { + a: string; +} + +//// [bar.ts] +import {Foo} from './foo'; +export class Bar extends Foo { + b: string; +} + +//// [foo.js] +System.register([], function(exports_1) { + var Foo; + return { + setters:[], + execute: function() { + Foo = (function () { + function Foo() { + } + return Foo; + })(); + exports_1("Foo", Foo); + } + } +}); +//// [bar.js] +System.register(['./foo'], function(exports_1) { + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var foo_1; + var Bar; + return { + setters:[ + function (foo_1_1) { + foo_1 = foo_1_1; + }], + execute: function() { + Bar = (function (_super) { + __extends(Bar, _super); + function Bar() { + _super.apply(this, arguments); + } + return Bar; + })(foo_1.Foo); + exports_1("Bar", Bar); + } + } +}); diff --git a/tests/baselines/reference/systemModuleWithSuperClass.symbols b/tests/baselines/reference/systemModuleWithSuperClass.symbols new file mode 100644 index 00000000000..46354333479 --- /dev/null +++ b/tests/baselines/reference/systemModuleWithSuperClass.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/foo.ts === + +export class Foo { +>Foo : Symbol(Foo, Decl(foo.ts, 0, 0)) + + a: string; +>a : Symbol(a, Decl(foo.ts, 1, 18)) +} + +=== tests/cases/compiler/bar.ts === +import {Foo} from './foo'; +>Foo : Symbol(Foo, Decl(bar.ts, 0, 8)) + +export class Bar extends Foo { +>Bar : Symbol(Bar, Decl(bar.ts, 0, 26)) +>Foo : Symbol(Foo, Decl(bar.ts, 0, 8)) + + b: string; +>b : Symbol(b, Decl(bar.ts, 1, 30)) +} diff --git a/tests/baselines/reference/systemModuleWithSuperClass.types b/tests/baselines/reference/systemModuleWithSuperClass.types new file mode 100644 index 00000000000..130f53f0ce3 --- /dev/null +++ b/tests/baselines/reference/systemModuleWithSuperClass.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/foo.ts === + +export class Foo { +>Foo : Foo + + a: string; +>a : string +} + +=== tests/cases/compiler/bar.ts === +import {Foo} from './foo'; +>Foo : typeof Foo + +export class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + b: string; +>b : string +} diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index baa4613d26b..42a865e4e28 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1)) diff --git a/tests/baselines/reference/tsxAttributeResolution10.errors.txt b/tests/baselines/reference/tsxAttributeResolution10.errors.txt new file mode 100644 index 00000000000..c929756364c --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution10.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type 'string' is not assignable to type 'boolean'. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } + } + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + export class MyComponent { + render() { + } + + props: { + [s: string]: boolean; + } + } + + // Should be an error + ; + ~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + + // Should be OK + ; + + // Should be ok + ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution10.js b/tests/baselines/reference/tsxAttributeResolution10.js new file mode 100644 index 00000000000..35e5b3074b0 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution10.js @@ -0,0 +1,50 @@ +//// [tests/cases/conformance/jsx/tsxAttributeResolution10.tsx] //// + +//// [react.d.ts] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } +} + +//// [file.tsx] +export class MyComponent { + render() { + } + + props: { + [s: string]: boolean; + } +} + +// Should be an error +; + +// Should be OK +; + +// Should be ok +; + + +//// [file.jsx] +define(["require", "exports"], function (require, exports) { + var MyComponent = (function () { + function MyComponent() { + } + MyComponent.prototype.render = function () { + }; + return MyComponent; + })(); + exports.MyComponent = MyComponent; + // Should be an error + ; + // Should be OK + ; + // Should be ok + ; +}); diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types index cd6265de091..613835f3211 100644 --- a/tests/baselines/reference/tsxElementResolution13.types +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -25,4 +25,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types index ef03187d28e..80f9555030f 100644 --- a/tests/baselines/reference/tsxElementResolution14.types +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -20,4 +20,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt index 5710c4e177d..92ff05d1aed 100644 --- a/tests/baselines/reference/tsxElementResolution8.errors.txt +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element type 'Div' does not have any construct or call signatures. -tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. -==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== +==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (2 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { } @@ -23,8 +21,6 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e // Error function Fnum(): number{ return 42; } - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. interface Obj1 { new(): {}; @@ -38,8 +34,6 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e } var Obj2: Obj2; ; // Error - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. interface Obj3 { } diff --git a/tests/baselines/reference/tsxElementResolution9.errors.txt b/tests/baselines/reference/tsxElementResolution9.errors.txt deleted file mode 100644 index 64514eebc00..00000000000 --- a/tests/baselines/reference/tsxElementResolution9.errors.txt +++ /dev/null @@ -1,38 +0,0 @@ -tests/cases/conformance/jsx/tsxElementResolution9.tsx(11,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution9.tsx(18,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution9.tsx(25,2): error TS2601: The return type of a JSX element constructor must return an object type. - - -==== tests/cases/conformance/jsx/tsxElementResolution9.tsx (3 errors) ==== - declare module JSX { - interface Element { } - interface IntrinsicElements { } - } - - interface Obj1 { - new(n: string): { x: number }; - new(n: number): { y: string }; - } - var Obj1: Obj1; - ; // Error, return type is not an object type - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. - - interface Obj2 { - (n: string): { x: number }; - (n: number): { y: string }; - } - var Obj2: Obj2; - ; // Error, return type is not an object type - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. - - interface Obj3 { - (n: string): { x: number }; - (n: number): { x: number; y: string }; - } - var Obj3: Obj3; - ; // OK - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. - \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution9.symbols b/tests/baselines/reference/tsxElementResolution9.symbols new file mode 100644 index 00000000000..bfa04219ef9 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.symbols @@ -0,0 +1,67 @@ +=== tests/cases/conformance/jsx/tsxElementResolution9.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution9.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution9.tsx, 0, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution9.tsx, 1, 22)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + + new(n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 6, 5)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 6, 18)) + + new(n: number): { y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 7, 5)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 7, 18)) +} +var Obj1: Obj1; +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + +; // Error, return type is not an object type +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + +interface Obj2 { +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + + (n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 13, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 13, 15)) + + (n: number): { y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 14, 2)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 14, 15)) +} +var Obj2: Obj2; +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + +; // Error, return type is not an object type +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + +interface Obj3 { +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) + + (n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 20, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 20, 15)) + + (n: number): { x: number; y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 21, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 21, 15)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 21, 26)) +} +var Obj3: Obj3; +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) + +; // OK +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types new file mode 100644 index 00000000000..6725bd216bd --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -0,0 +1,71 @@ +=== tests/cases/conformance/jsx/tsxElementResolution9.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): { x: number }; +>n : string +>x : number + + new(n: number): { y: string }; +>n : number +>y : string +} +var Obj1: Obj1; +>Obj1 : Obj1 +>Obj1 : Obj1 + +; // Error, return type is not an object type +> : JSX.Element +>Obj1 : Obj1 + +interface Obj2 { +>Obj2 : Obj2 + + (n: string): { x: number }; +>n : string +>x : number + + (n: number): { y: string }; +>n : number +>y : string +} +var Obj2: Obj2; +>Obj2 : Obj2 +>Obj2 : Obj2 + +; // Error, return type is not an object type +> : JSX.Element +>Obj2 : Obj2 + +interface Obj3 { +>Obj3 : Obj3 + + (n: string): { x: number }; +>n : string +>x : number + + (n: number): { x: number; y: string }; +>n : number +>x : number +>y : string +} +var Obj3: Obj3; +>Obj3 : Obj3 +>Obj3 : Obj3 + +; // OK +> : JSX.Element +>Obj3 : Obj3 +>x : any +>42 : number + diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols index 284f6cd9ce7..aaca98ae9db 100644 --- a/tests/baselines/reference/tsxEmit1.symbols +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -52,21 +52,26 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >y : Symbol(unknown) var openClosed1 =
; >openClosed1 : Symbol(openClosed1, Decl(tsxEmit1.tsx, 16, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed2 =
foo
; >openClosed2 : Symbol(openClosed2, Decl(tsxEmit1.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; >openClosed4 : Symbol(openClosed4, Decl(tsxEmit1.tsx, 19, 3)) @@ -74,6 +79,7 @@ var openClosed4 =
{p < p}
; >n : Symbol(unknown) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed5 =
{p > p}
; >openClosed5 : Symbol(openClosed5, Decl(tsxEmit1.tsx, 20, 3)) @@ -81,6 +87,7 @@ var openClosed5 =
{p > p}
; >n : Symbol(unknown) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) class SomeClass { >SomeClass : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) @@ -92,6 +99,7 @@ class SomeClass { >rewrites1 : Symbol(rewrites1, Decl(tsxEmit1.tsx, 24, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var rewrites2 =
{[p, ...p, p]}
; >rewrites2 : Symbol(rewrites2, Decl(tsxEmit1.tsx, 25, 5)) @@ -99,17 +107,20 @@ class SomeClass { >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var rewrites3 =
{{p}}
; >rewrites3 : Symbol(rewrites3, Decl(tsxEmit1.tsx, 26, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >p : Symbol(p, Decl(tsxEmit1.tsx, 26, 25)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var rewrites4 =
this}>
; >rewrites4 : Symbol(rewrites4, Decl(tsxEmit1.tsx, 28, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >a : Symbol(unknown) >this : Symbol(SomeClass, Decl(tsxEmit1.tsx, 20, 43)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var rewrites5 =
; >rewrites5 : Symbol(rewrites5, Decl(tsxEmit1.tsx, 29, 5)) @@ -118,27 +129,35 @@ class SomeClass { >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var rewrites6 =
; >rewrites6 : Symbol(rewrites6, Decl(tsxEmit1.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >a : Symbol(unknown) >p : Symbol(p, Decl(tsxEmit1.tsx, 30, 27)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) } } var whitespace1 =
; >whitespace1 : Symbol(whitespace1, Decl(tsxEmit1.tsx, 34, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var whitespace3 =
>whitespace3 : Symbol(whitespace3, Decl(tsxEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) {p} -
; +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) + +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index 667ec113337..a427270354e 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -45,6 +45,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -52,6 +53,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols index 28f6a9f5026..5eefc31710d 100644 --- a/tests/baselines/reference/tsxEmit2.symbols +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -21,24 +21,38 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxEmit3.js b/tests/baselines/reference/tsxEmit3.js index beae73e2bf1..aa958a0c79b 100644 --- a/tests/baselines/reference/tsxEmit3.js +++ b/tests/baselines/reference/tsxEmit3.js @@ -1,4 +1,5 @@ //// [tsxEmit3.tsx] + declare module JSX { interface Element { } interface IntrinsicElements { } @@ -82,3 +83,4 @@ var M; // Emit M_1.Foo M_1.Foo, ; })(M || (M = {})); +//# sourceMappingURL=tsxEmit3.jsx.map \ No newline at end of file diff --git a/tests/baselines/reference/tsxEmit3.js.map b/tests/baselines/reference/tsxEmit3.js.map new file mode 100644 index 00000000000..1f1ba0926a0 --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.js.map @@ -0,0 +1,2 @@ +//// [tsxEmit3.jsx.map] +{"version":3,"file":"tsxEmit3.jsx","sourceRoot":"","sources":["tsxEmit3.tsx"],"names":["M","M.Foo","M.Foo.constructor","M.S","M.S.Bar","M.S.Bar.constructor"],"mappings":"AAMA,IAAO,CAAC,CAQP;AARD,WAAO,CAAC,EAAC,CAAC;IACTA;QAAmBC;QAAgBC,CAACA;QAACD,UAACA;IAADA,CAACA,AAAtCD,IAAsCA;IAAzBA,KAAGA,MAAsBA,CAAAA;IACtCA,IAAcA,CAACA,CAKdA;IALDA,WAAcA,CAACA,EAACA,CAACA;QAChBG;YAAAC;YAAmBC,CAACA;YAADD,UAACA;QAADA,CAACA,AAApBD,IAAoBA;QAAPA,KAAGA,MAAIA,CAAAA;IAIrBA,CAACA,EALaH,CAACA,GAADA,GAACA,KAADA,GAACA,QAKdA;AACFA,CAACA,EARM,CAAC,KAAD,CAAC,QAQP;AAED,IAAO,CAAC,CAYP;AAZD,WAAO,CAAC,EAAC,CAAC;IACTA,aAAaA;IACbA,KAAGA,EAAEA,CAACA,KAAGA,GAAGA,CAACA;IAEbA,IAAcA,CAACA,CAMdA;IANDA,WAAcA,CAACA,EAACA,CAACA;QAChBG,aAAaA;QACbA,KAAGA,EAAEA,CAACA,KAAGA,GAAGA,CAACA;QAEbA,aAAaA;QACbA,KAAGA,EAAEA,CAACA,KAAGA,GAAGA,CAACA;IACdA,CAACA,EANaH,CAACA,GAADA,GAACA,KAADA,GAACA,QAMdA;AAEFA,CAACA,EAZM,CAAC,KAAD,CAAC,QAYP;AAED,IAAO,CAAC,CAGP;AAHD,WAAO,CAAC,EAAC,CAAC;IACTA,eAAeA;IACfA,GAACA,CAACA,GAAGA,EAAEA,CAACA,GAACA,CAACA,GAAGA,GAAGA,CAACA;AAClBA,CAACA,EAHM,CAAC,KAAD,CAAC,QAGP;AAED,IAAO,CAAC,CAIP;AAJD,WAAO,GAAC,EAAC,CAAC;IACTA,IAAIA,CAACA,GAAGA,GAAGA,CAACA;IACZA,eAAeA;IACfA,OAAGA,EAAEA,CAACA,OAAGA,GAAGA,CAACA;AACdA,CAACA,EAJM,CAAC,KAAD,CAAC,QAIP"} \ No newline at end of file diff --git a/tests/baselines/reference/tsxEmit3.sourcemap.txt b/tests/baselines/reference/tsxEmit3.sourcemap.txt new file mode 100644 index 00000000000..514be1e532d --- /dev/null +++ b/tests/baselines/reference/tsxEmit3.sourcemap.txt @@ -0,0 +1,785 @@ +=================================================================== +JsFile: tsxEmit3.jsx +mapUrl: tsxEmit3.jsx.map +sourceRoot: +sources: tsxEmit3.tsx +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/conformance/jsx/tsxEmit3.jsx +sourceFile:tsxEmit3.tsx +------------------------------------------------------------------- +>>>var M; +1 > +2 >^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > + >declare module JSX { + > interface Element { } + > interface IntrinsicElements { } + >} + > + > +2 >module +3 > M +4 > { + > export class Foo { constructor() { } } + > export module S { + > export class Bar { } + > + > // Emit Foo + > // Foo, ; + > } + > } +1 >Emitted(1, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(7, 8) + SourceIndex(0) +3 >Emitted(1, 6) Source(7, 9) + SourceIndex(0) +4 >Emitted(1, 7) Source(15, 2) + SourceIndex(0) +--- +>>>(function (M) { +1-> +2 >^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^-> +1-> +2 >module +3 > M +4 > +5 > { +1->Emitted(2, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(2, 12) Source(7, 8) + SourceIndex(0) +3 >Emitted(2, 13) Source(7, 9) + SourceIndex(0) +4 >Emitted(2, 15) Source(7, 10) + SourceIndex(0) +5 >Emitted(2, 16) Source(7, 11) + SourceIndex(0) +--- +>>> var Foo = (function () { +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(3, 5) Source(8, 2) + SourceIndex(0) name (M) +--- +>>> function Foo() { +1->^^^^^^^^ +2 > ^^-> +1->export class Foo { +1->Emitted(4, 9) Source(8, 21) + SourceIndex(0) name (M.Foo) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^-> +1->constructor() { +2 > } +1->Emitted(5, 9) Source(8, 37) + SourceIndex(0) name (M.Foo.constructor) +2 >Emitted(5, 10) Source(8, 38) + SourceIndex(0) name (M.Foo.constructor) +--- +>>> return Foo; +1->^^^^^^^^ +2 > ^^^^^^^^^^ +1-> +2 > } +1->Emitted(6, 9) Source(8, 39) + SourceIndex(0) name (M.Foo) +2 >Emitted(6, 19) Source(8, 40) + SourceIndex(0) name (M.Foo) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^-> +1 > +2 > } +3 > +4 > export class Foo { constructor() { } } +1 >Emitted(7, 5) Source(8, 39) + SourceIndex(0) name (M.Foo) +2 >Emitted(7, 6) Source(8, 40) + SourceIndex(0) name (M.Foo) +3 >Emitted(7, 6) Source(8, 2) + SourceIndex(0) name (M) +4 >Emitted(7, 10) Source(8, 40) + SourceIndex(0) name (M) +--- +>>> M.Foo = Foo; +1->^^^^ +2 > ^^^^^ +3 > ^^^^^^ +4 > ^ +1-> +2 > Foo +3 > { constructor() { } } +4 > +1->Emitted(8, 5) Source(8, 15) + SourceIndex(0) name (M) +2 >Emitted(8, 10) Source(8, 18) + SourceIndex(0) name (M) +3 >Emitted(8, 16) Source(8, 40) + SourceIndex(0) name (M) +4 >Emitted(8, 17) Source(8, 40) + SourceIndex(0) name (M) +--- +>>> var S; +1 >^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > + > +2 > export module +3 > S +4 > { + > export class Bar { } + > + > // Emit Foo + > // Foo, ; + > } +1 >Emitted(9, 5) Source(9, 2) + SourceIndex(0) name (M) +2 >Emitted(9, 9) Source(9, 16) + SourceIndex(0) name (M) +3 >Emitted(9, 10) Source(9, 17) + SourceIndex(0) name (M) +4 >Emitted(9, 11) Source(14, 3) + SourceIndex(0) name (M) +--- +>>> (function (S) { +1->^^^^ +2 > ^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^-> +1-> +2 > export module +3 > S +4 > +5 > { +1->Emitted(10, 5) Source(9, 2) + SourceIndex(0) name (M) +2 >Emitted(10, 16) Source(9, 16) + SourceIndex(0) name (M) +3 >Emitted(10, 17) Source(9, 17) + SourceIndex(0) name (M) +4 >Emitted(10, 19) Source(9, 18) + SourceIndex(0) name (M) +5 >Emitted(10, 20) Source(9, 19) + SourceIndex(0) name (M) +--- +>>> var Bar = (function () { +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +1->Emitted(11, 9) Source(10, 3) + SourceIndex(0) name (M.S) +--- +>>> function Bar() { +1->^^^^^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(12, 13) Source(10, 3) + SourceIndex(0) name (M.S.Bar) +--- +>>> } +1->^^^^^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^-> +1->export class Bar { +2 > } +1->Emitted(13, 13) Source(10, 22) + SourceIndex(0) name (M.S.Bar.constructor) +2 >Emitted(13, 14) Source(10, 23) + SourceIndex(0) name (M.S.Bar.constructor) +--- +>>> return Bar; +1->^^^^^^^^^^^^ +2 > ^^^^^^^^^^ +1-> +2 > } +1->Emitted(14, 13) Source(10, 22) + SourceIndex(0) name (M.S.Bar) +2 >Emitted(14, 23) Source(10, 23) + SourceIndex(0) name (M.S.Bar) +--- +>>> })(); +1 >^^^^^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^-> +1 > +2 > } +3 > +4 > export class Bar { } +1 >Emitted(15, 9) Source(10, 22) + SourceIndex(0) name (M.S.Bar) +2 >Emitted(15, 10) Source(10, 23) + SourceIndex(0) name (M.S.Bar) +3 >Emitted(15, 10) Source(10, 3) + SourceIndex(0) name (M.S) +4 >Emitted(15, 14) Source(10, 23) + SourceIndex(0) name (M.S) +--- +>>> S.Bar = Bar; +1->^^^^^^^^ +2 > ^^^^^ +3 > ^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^-> +1-> +2 > Bar +3 > { } +4 > +1->Emitted(16, 9) Source(10, 16) + SourceIndex(0) name (M.S) +2 >Emitted(16, 14) Source(10, 19) + SourceIndex(0) name (M.S) +3 >Emitted(16, 20) Source(10, 23) + SourceIndex(0) name (M.S) +4 >Emitted(16, 21) Source(10, 23) + SourceIndex(0) name (M.S) +--- +>>> })(S = M.S || (M.S = {})); +1->^^^^ +2 > ^ +3 > ^^ +4 > ^ +5 > ^^^ +6 > ^^^ +7 > ^^^^^ +8 > ^^^ +9 > ^^^^^^^^ +1-> + > + > // Emit Foo + > // Foo, ; + > +2 > } +3 > +4 > S +5 > +6 > S +7 > +8 > S +9 > { + > export class Bar { } + > + > // Emit Foo + > // Foo, ; + > } +1->Emitted(17, 5) Source(14, 2) + SourceIndex(0) name (M.S) +2 >Emitted(17, 6) Source(14, 3) + SourceIndex(0) name (M.S) +3 >Emitted(17, 8) Source(9, 16) + SourceIndex(0) name (M) +4 >Emitted(17, 9) Source(9, 17) + SourceIndex(0) name (M) +5 >Emitted(17, 12) Source(9, 16) + SourceIndex(0) name (M) +6 >Emitted(17, 15) Source(9, 17) + SourceIndex(0) name (M) +7 >Emitted(17, 20) Source(9, 16) + SourceIndex(0) name (M) +8 >Emitted(17, 23) Source(9, 17) + SourceIndex(0) name (M) +9 >Emitted(17, 31) Source(14, 3) + SourceIndex(0) name (M) +--- +>>>})(M || (M = {})); +1 > +2 >^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^ +7 > ^^^^^^^^ +1 > + > +2 >} +3 > +4 > M +5 > +6 > M +7 > { + > export class Foo { constructor() { } } + > export module S { + > export class Bar { } + > + > // Emit Foo + > // Foo, ; + > } + > } +1 >Emitted(18, 1) Source(15, 1) + SourceIndex(0) name (M) +2 >Emitted(18, 2) Source(15, 2) + SourceIndex(0) name (M) +3 >Emitted(18, 4) Source(7, 8) + SourceIndex(0) +4 >Emitted(18, 5) Source(7, 9) + SourceIndex(0) +5 >Emitted(18, 10) Source(7, 8) + SourceIndex(0) +6 >Emitted(18, 11) Source(7, 9) + SourceIndex(0) +7 >Emitted(18, 19) Source(15, 2) + SourceIndex(0) +--- +>>>var M; +1 > +2 >^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > + > + > +2 >module +3 > M +4 > { + > // Emit M.Foo + > Foo, ; + > + > export module S { + > // Emit M.Foo + > Foo, ; + > + > // Emit S.Bar + > Bar, ; + > } + > + > } +1 >Emitted(19, 1) Source(17, 1) + SourceIndex(0) +2 >Emitted(19, 5) Source(17, 8) + SourceIndex(0) +3 >Emitted(19, 6) Source(17, 9) + SourceIndex(0) +4 >Emitted(19, 7) Source(29, 2) + SourceIndex(0) +--- +>>>(function (M) { +1-> +2 >^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^-> +1-> +2 >module +3 > M +4 > +5 > { +1->Emitted(20, 1) Source(17, 1) + SourceIndex(0) +2 >Emitted(20, 12) Source(17, 8) + SourceIndex(0) +3 >Emitted(20, 13) Source(17, 9) + SourceIndex(0) +4 >Emitted(20, 15) Source(17, 10) + SourceIndex(0) +5 >Emitted(20, 16) Source(17, 11) + SourceIndex(0) +--- +>>> // Emit M.Foo +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^-> +1-> + > +2 > // Emit M.Foo +1->Emitted(21, 5) Source(18, 2) + SourceIndex(0) name (M) +2 >Emitted(21, 18) Source(18, 15) + SourceIndex(0) name (M) +--- +>>> M.Foo, ; +1->^^^^ +2 > ^^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^^^ +7 > ^ +1-> + > +2 > Foo +3 > , +4 > < +5 > Foo +6 > /> +7 > ; +1->Emitted(22, 5) Source(19, 2) + SourceIndex(0) name (M) +2 >Emitted(22, 10) Source(19, 5) + SourceIndex(0) name (M) +3 >Emitted(22, 12) Source(19, 7) + SourceIndex(0) name (M) +4 >Emitted(22, 13) Source(19, 8) + SourceIndex(0) name (M) +5 >Emitted(22, 18) Source(19, 11) + SourceIndex(0) name (M) +6 >Emitted(22, 21) Source(19, 14) + SourceIndex(0) name (M) +7 >Emitted(22, 22) Source(19, 15) + SourceIndex(0) name (M) +--- +>>> var S; +1 >^^^^ +2 > ^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > + > + > +2 > export module +3 > S +4 > { + > // Emit M.Foo + > Foo, ; + > + > // Emit S.Bar + > Bar, ; + > } +1 >Emitted(23, 5) Source(21, 2) + SourceIndex(0) name (M) +2 >Emitted(23, 9) Source(21, 16) + SourceIndex(0) name (M) +3 >Emitted(23, 10) Source(21, 17) + SourceIndex(0) name (M) +4 >Emitted(23, 11) Source(27, 3) + SourceIndex(0) name (M) +--- +>>> (function (S) { +1->^^^^ +2 > ^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^-> +1-> +2 > export module +3 > S +4 > +5 > { +1->Emitted(24, 5) Source(21, 2) + SourceIndex(0) name (M) +2 >Emitted(24, 16) Source(21, 16) + SourceIndex(0) name (M) +3 >Emitted(24, 17) Source(21, 17) + SourceIndex(0) name (M) +4 >Emitted(24, 19) Source(21, 18) + SourceIndex(0) name (M) +5 >Emitted(24, 20) Source(21, 19) + SourceIndex(0) name (M) +--- +>>> // Emit M.Foo +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^-> +1-> + > +2 > // Emit M.Foo +1->Emitted(25, 9) Source(22, 3) + SourceIndex(0) name (M.S) +2 >Emitted(25, 22) Source(22, 16) + SourceIndex(0) name (M.S) +--- +>>> M.Foo, ; +1->^^^^^^^^ +2 > ^^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^^^ +7 > ^ +1-> + > +2 > Foo +3 > , +4 > < +5 > Foo +6 > /> +7 > ; +1->Emitted(26, 9) Source(23, 3) + SourceIndex(0) name (M.S) +2 >Emitted(26, 14) Source(23, 6) + SourceIndex(0) name (M.S) +3 >Emitted(26, 16) Source(23, 8) + SourceIndex(0) name (M.S) +4 >Emitted(26, 17) Source(23, 9) + SourceIndex(0) name (M.S) +5 >Emitted(26, 22) Source(23, 12) + SourceIndex(0) name (M.S) +6 >Emitted(26, 25) Source(23, 15) + SourceIndex(0) name (M.S) +7 >Emitted(26, 26) Source(23, 16) + SourceIndex(0) name (M.S) +--- +>>> // Emit S.Bar +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^^^-> +1 > + > + > +2 > // Emit S.Bar +1 >Emitted(27, 9) Source(25, 3) + SourceIndex(0) name (M.S) +2 >Emitted(27, 22) Source(25, 16) + SourceIndex(0) name (M.S) +--- +>>> S.Bar, ; +1->^^^^^^^^ +2 > ^^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^^^ +7 > ^ +8 > ^^^^^^-> +1-> + > +2 > Bar +3 > , +4 > < +5 > Bar +6 > /> +7 > ; +1->Emitted(28, 9) Source(26, 3) + SourceIndex(0) name (M.S) +2 >Emitted(28, 14) Source(26, 6) + SourceIndex(0) name (M.S) +3 >Emitted(28, 16) Source(26, 8) + SourceIndex(0) name (M.S) +4 >Emitted(28, 17) Source(26, 9) + SourceIndex(0) name (M.S) +5 >Emitted(28, 22) Source(26, 12) + SourceIndex(0) name (M.S) +6 >Emitted(28, 25) Source(26, 15) + SourceIndex(0) name (M.S) +7 >Emitted(28, 26) Source(26, 16) + SourceIndex(0) name (M.S) +--- +>>> })(S = M.S || (M.S = {})); +1->^^^^ +2 > ^ +3 > ^^ +4 > ^ +5 > ^^^ +6 > ^^^ +7 > ^^^^^ +8 > ^^^ +9 > ^^^^^^^^ +1-> + > +2 > } +3 > +4 > S +5 > +6 > S +7 > +8 > S +9 > { + > // Emit M.Foo + > Foo, ; + > + > // Emit S.Bar + > Bar, ; + > } +1->Emitted(29, 5) Source(27, 2) + SourceIndex(0) name (M.S) +2 >Emitted(29, 6) Source(27, 3) + SourceIndex(0) name (M.S) +3 >Emitted(29, 8) Source(21, 16) + SourceIndex(0) name (M) +4 >Emitted(29, 9) Source(21, 17) + SourceIndex(0) name (M) +5 >Emitted(29, 12) Source(21, 16) + SourceIndex(0) name (M) +6 >Emitted(29, 15) Source(21, 17) + SourceIndex(0) name (M) +7 >Emitted(29, 20) Source(21, 16) + SourceIndex(0) name (M) +8 >Emitted(29, 23) Source(21, 17) + SourceIndex(0) name (M) +9 >Emitted(29, 31) Source(27, 3) + SourceIndex(0) name (M) +--- +>>>})(M || (M = {})); +1 > +2 >^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^ +7 > ^^^^^^^^ +1 > + > + > +2 >} +3 > +4 > M +5 > +6 > M +7 > { + > // Emit M.Foo + > Foo, ; + > + > export module S { + > // Emit M.Foo + > Foo, ; + > + > // Emit S.Bar + > Bar, ; + > } + > + > } +1 >Emitted(30, 1) Source(29, 1) + SourceIndex(0) name (M) +2 >Emitted(30, 2) Source(29, 2) + SourceIndex(0) name (M) +3 >Emitted(30, 4) Source(17, 8) + SourceIndex(0) +4 >Emitted(30, 5) Source(17, 9) + SourceIndex(0) +5 >Emitted(30, 10) Source(17, 8) + SourceIndex(0) +6 >Emitted(30, 11) Source(17, 9) + SourceIndex(0) +7 >Emitted(30, 19) Source(29, 2) + SourceIndex(0) +--- +>>>var M; +1 > +2 >^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^-> +1 > + > + > +2 >module +3 > M +4 > { + > // Emit M.S.Bar + > S.Bar, ; + > } +1 >Emitted(31, 1) Source(31, 1) + SourceIndex(0) +2 >Emitted(31, 5) Source(31, 8) + SourceIndex(0) +3 >Emitted(31, 6) Source(31, 9) + SourceIndex(0) +4 >Emitted(31, 7) Source(34, 2) + SourceIndex(0) +--- +>>>(function (M) { +1-> +2 >^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^-> +1-> +2 >module +3 > M +4 > +5 > { +1->Emitted(32, 1) Source(31, 1) + SourceIndex(0) +2 >Emitted(32, 12) Source(31, 8) + SourceIndex(0) +3 >Emitted(32, 13) Source(31, 9) + SourceIndex(0) +4 >Emitted(32, 15) Source(31, 10) + SourceIndex(0) +5 >Emitted(32, 16) Source(31, 11) + SourceIndex(0) +--- +>>> // Emit M.S.Bar +1->^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^^^^^^^-> +1-> + > +2 > // Emit M.S.Bar +1->Emitted(33, 5) Source(32, 2) + SourceIndex(0) name (M) +2 >Emitted(33, 20) Source(32, 17) + SourceIndex(0) name (M) +--- +>>> M.S.Bar, ; +1->^^^^ +2 > ^^^ +3 > ^ +4 > ^^^ +5 > ^^ +6 > ^ +7 > ^^^ +8 > ^ +9 > ^^^ +10> ^^^ +11> ^ +1-> + > +2 > S +3 > . +4 > Bar +5 > , +6 > < +7 > S +8 > . +9 > Bar +10> /> +11> ; +1->Emitted(34, 5) Source(33, 2) + SourceIndex(0) name (M) +2 >Emitted(34, 8) Source(33, 3) + SourceIndex(0) name (M) +3 >Emitted(34, 9) Source(33, 4) + SourceIndex(0) name (M) +4 >Emitted(34, 12) Source(33, 7) + SourceIndex(0) name (M) +5 >Emitted(34, 14) Source(33, 9) + SourceIndex(0) name (M) +6 >Emitted(34, 15) Source(33, 10) + SourceIndex(0) name (M) +7 >Emitted(34, 18) Source(33, 11) + SourceIndex(0) name (M) +8 >Emitted(34, 19) Source(33, 12) + SourceIndex(0) name (M) +9 >Emitted(34, 22) Source(33, 15) + SourceIndex(0) name (M) +10>Emitted(34, 25) Source(33, 18) + SourceIndex(0) name (M) +11>Emitted(34, 26) Source(33, 19) + SourceIndex(0) name (M) +--- +>>>})(M || (M = {})); +1 > +2 >^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^ +7 > ^^^^^^^^ +1 > + > +2 >} +3 > +4 > M +5 > +6 > M +7 > { + > // Emit M.S.Bar + > S.Bar, ; + > } +1 >Emitted(35, 1) Source(34, 1) + SourceIndex(0) name (M) +2 >Emitted(35, 2) Source(34, 2) + SourceIndex(0) name (M) +3 >Emitted(35, 4) Source(31, 8) + SourceIndex(0) +4 >Emitted(35, 5) Source(31, 9) + SourceIndex(0) +5 >Emitted(35, 10) Source(31, 8) + SourceIndex(0) +6 >Emitted(35, 11) Source(31, 9) + SourceIndex(0) +7 >Emitted(35, 19) Source(34, 2) + SourceIndex(0) +--- +>>>var M; +1 > +2 >^^^^ +3 > ^ +4 > ^ +5 > ^^^^^^^^^^^^-> +1 > + > + > +2 >module +3 > M +4 > { + > var M = 100; + > // Emit M_1.Foo + > Foo, ; + > } +1 >Emitted(36, 1) Source(36, 1) + SourceIndex(0) +2 >Emitted(36, 5) Source(36, 8) + SourceIndex(0) +3 >Emitted(36, 6) Source(36, 9) + SourceIndex(0) +4 >Emitted(36, 7) Source(40, 2) + SourceIndex(0) +--- +>>>(function (M_1) { +1-> +2 >^^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +1-> +2 >module +3 > M +4 > +5 > { +1->Emitted(37, 1) Source(36, 1) + SourceIndex(0) +2 >Emitted(37, 12) Source(36, 8) + SourceIndex(0) +3 >Emitted(37, 15) Source(36, 9) + SourceIndex(0) +4 >Emitted(37, 17) Source(36, 10) + SourceIndex(0) +5 >Emitted(37, 18) Source(36, 11) + SourceIndex(0) +--- +>>> var M = 100; +1 >^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^^^ +6 > ^ +7 > ^^^^-> +1 > + > +2 > var +3 > M +4 > = +5 > 100 +6 > ; +1 >Emitted(38, 5) Source(37, 2) + SourceIndex(0) name (M) +2 >Emitted(38, 9) Source(37, 6) + SourceIndex(0) name (M) +3 >Emitted(38, 10) Source(37, 7) + SourceIndex(0) name (M) +4 >Emitted(38, 13) Source(37, 10) + SourceIndex(0) name (M) +5 >Emitted(38, 16) Source(37, 13) + SourceIndex(0) name (M) +6 >Emitted(38, 17) Source(37, 14) + SourceIndex(0) name (M) +--- +>>> // Emit M_1.Foo +1->^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^^^^^^^-> +1-> + > +2 > // Emit M_1.Foo +1->Emitted(39, 5) Source(38, 2) + SourceIndex(0) name (M) +2 >Emitted(39, 20) Source(38, 17) + SourceIndex(0) name (M) +--- +>>> M_1.Foo, ; +1->^^^^ +2 > ^^^^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^ +6 > ^^^ +7 > ^ +1-> + > +2 > Foo +3 > , +4 > < +5 > Foo +6 > /> +7 > ; +1->Emitted(40, 5) Source(39, 2) + SourceIndex(0) name (M) +2 >Emitted(40, 12) Source(39, 5) + SourceIndex(0) name (M) +3 >Emitted(40, 14) Source(39, 7) + SourceIndex(0) name (M) +4 >Emitted(40, 15) Source(39, 8) + SourceIndex(0) name (M) +5 >Emitted(40, 22) Source(39, 11) + SourceIndex(0) name (M) +6 >Emitted(40, 25) Source(39, 14) + SourceIndex(0) name (M) +7 >Emitted(40, 26) Source(39, 15) + SourceIndex(0) name (M) +--- +>>>})(M || (M = {})); +1 > +2 >^ +3 > ^^ +4 > ^ +5 > ^^^^^ +6 > ^ +7 > ^^^^^^^^ +8 > ^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +3 > +4 > M +5 > +6 > M +7 > { + > var M = 100; + > // Emit M_1.Foo + > Foo, ; + > } +1 >Emitted(41, 1) Source(40, 1) + SourceIndex(0) name (M) +2 >Emitted(41, 2) Source(40, 2) + SourceIndex(0) name (M) +3 >Emitted(41, 4) Source(36, 8) + SourceIndex(0) +4 >Emitted(41, 5) Source(36, 9) + SourceIndex(0) +5 >Emitted(41, 10) Source(36, 8) + SourceIndex(0) +6 >Emitted(41, 11) Source(36, 9) + SourceIndex(0) +7 >Emitted(41, 19) Source(40, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=tsxEmit3.jsx.map \ No newline at end of file diff --git a/tests/baselines/reference/tsxEmit3.symbols b/tests/baselines/reference/tsxEmit3.symbols index 4ceed0b9b1e..64542d125b9 100644 --- a/tests/baselines/reference/tsxEmit3.symbols +++ b/tests/baselines/reference/tsxEmit3.symbols @@ -1,25 +1,26 @@ === tests/cases/conformance/jsx/tsxEmit3.tsx === + declare module JSX { >JSX : Symbol(JSX, Decl(tsxEmit3.tsx, 0, 0)) interface Element { } ->Element : Symbol(Element, Decl(tsxEmit3.tsx, 0, 20)) +>Element : Symbol(Element, Decl(tsxEmit3.tsx, 1, 20)) interface IntrinsicElements { } ->IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit3.tsx, 1, 22)) +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxEmit3.tsx, 2, 22)) } module M { ->M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) +>M : Symbol(M, Decl(tsxEmit3.tsx, 4, 1), Decl(tsxEmit3.tsx, 14, 1), Decl(tsxEmit3.tsx, 28, 1), Decl(tsxEmit3.tsx, 33, 1)) export class Foo { constructor() { } } ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) export module S { ->S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 7, 39), Decl(tsxEmit3.tsx, 18, 14)) export class Bar { } ->Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 8, 18)) // Emit Foo // Foo, ; @@ -27,49 +28,49 @@ module M { } module M { ->M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) +>M : Symbol(M, Decl(tsxEmit3.tsx, 4, 1), Decl(tsxEmit3.tsx, 14, 1), Decl(tsxEmit3.tsx, 28, 1), Decl(tsxEmit3.tsx, 33, 1)) // Emit M.Foo Foo, ; ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) export module S { ->S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 7, 39), Decl(tsxEmit3.tsx, 18, 14)) // Emit M.Foo Foo, ; ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) // Emit S.Bar Bar, ; ->Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) ->Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 7, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 8, 18)) +>Bar : Symbol(Bar, Decl(tsxEmit3.tsx, 8, 18)) } } module M { ->M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) +>M : Symbol(M, Decl(tsxEmit3.tsx, 4, 1), Decl(tsxEmit3.tsx, 14, 1), Decl(tsxEmit3.tsx, 28, 1), Decl(tsxEmit3.tsx, 33, 1)) // Emit M.S.Bar S.Bar, ; ->S.Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) ->S : Symbol(S, Decl(tsxEmit3.tsx, 6, 39), Decl(tsxEmit3.tsx, 17, 14)) ->Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) ->Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 7, 18)) +>S.Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 8, 18)) +>S : Symbol(S, Decl(tsxEmit3.tsx, 7, 39), Decl(tsxEmit3.tsx, 18, 14)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 8, 18)) +>Bar : Symbol(S.Bar, Decl(tsxEmit3.tsx, 8, 18)) } module M { ->M : Symbol(M, Decl(tsxEmit3.tsx, 3, 1), Decl(tsxEmit3.tsx, 13, 1), Decl(tsxEmit3.tsx, 27, 1), Decl(tsxEmit3.tsx, 32, 1)) +>M : Symbol(M, Decl(tsxEmit3.tsx, 4, 1), Decl(tsxEmit3.tsx, 14, 1), Decl(tsxEmit3.tsx, 28, 1), Decl(tsxEmit3.tsx, 33, 1)) var M = 100; ->M : Symbol(M, Decl(tsxEmit3.tsx, 35, 4)) +>M : Symbol(M, Decl(tsxEmit3.tsx, 36, 4)) // Emit M_1.Foo Foo, ; ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) ->Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 5, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) +>Foo : Symbol(Foo, Decl(tsxEmit3.tsx, 6, 10)) } diff --git a/tests/baselines/reference/tsxEmit3.types b/tests/baselines/reference/tsxEmit3.types index 4bb92d9aea5..f4db9a3f36f 100644 --- a/tests/baselines/reference/tsxEmit3.types +++ b/tests/baselines/reference/tsxEmit3.types @@ -1,4 +1,5 @@ === tests/cases/conformance/jsx/tsxEmit3.tsx === + declare module JSX { >JSX : any diff --git a/tests/baselines/reference/tsxErrorRecovery1.errors.txt b/tests/baselines/reference/tsxErrorRecovery1.errors.txt index dc4f4d51afe..7aea986526b 100644 --- a/tests/baselines/reference/tsxErrorRecovery1.errors.txt +++ b/tests/baselines/reference/tsxErrorRecovery1.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(5,19): error TS1109: Expression expected. +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(8,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(8,12): error TS1005: '}' expected. +tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(9,1): error TS17002: Expected corresponding JSX closing tag for 'div'. -==== tests/cases/conformance/jsx/tsxErrorRecovery1.tsx (1 errors) ==== +==== tests/cases/conformance/jsx/tsxErrorRecovery1.tsx (4 errors) ==== declare namespace JSX { interface Element { } } @@ -12,4 +15,10 @@ tests/cases/conformance/jsx/tsxErrorRecovery1.tsx(5,19): error TS1109: Expressio } // Shouldn't see any errors down here var y = { a: 1 }; - \ No newline at end of file + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: '}' expected. + + +!!! error TS17002: Expected corresponding JSX closing tag for 'div'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxErrorRecovery1.js b/tests/baselines/reference/tsxErrorRecovery1.js index 8d20951f6ed..62db6b0f012 100644 --- a/tests/baselines/reference/tsxErrorRecovery1.js +++ b/tests/baselines/reference/tsxErrorRecovery1.js @@ -11,7 +11,9 @@ var y = { a: 1 }; //// [tsxErrorRecovery1.jsx] function foo() { - var x =
{}
; + var x =
{}div> +} +// Shouldn't see any errors down here +var y = {a} 1 }; +; } -// Shouldn't see any errors down here -var y = { a: 1 }; diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js new file mode 100644 index 00000000000..f8fe6096090 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx] //// + +//// [modules.d.ts] + +declare module 'mod' { + var y: any; + export default y; +} + +//// [app.tsx] +import Main from 'mod'; +declare var Foo, React; +// Should see mod_1['default'] in emit here +; +// Should see mod_1['default'] in emit here +; + + + +//// [app.js] +var mod_1 = require('mod'); +// Should see mod_1['default'] in emit here +React.createElement(Foo, {"handler": mod_1["default"]}); +// Should see mod_1['default'] in emit here +React.createElement(Foo, React.__spread({}, mod_1["default"])); diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.symbols b/tests/baselines/reference/tsxExternalModuleEmit2.symbols new file mode 100644 index 00000000000..6f8d3d76cd2 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit2.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/jsx/modules.d.ts === + +declare module 'mod' { + var y: any; +>y : Symbol(y, Decl(modules.d.ts, 2, 5)) + + export default y; +>y : Symbol(y, Decl(modules.d.ts, 2, 5)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import Main from 'mod'; +>Main : Symbol(Main, Decl(app.tsx, 0, 6)) + +declare var Foo, React; +>Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) +>React : Symbol(React, Decl(app.tsx, 1, 16)) + +// Should see mod_1['default'] in emit here +; +>Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) +>handler : Symbol(unknown) +>Main : Symbol(Main, Decl(app.tsx, 0, 6)) +>Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) + +// Should see mod_1['default'] in emit here +; +>Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) +>Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) + + diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.types b/tests/baselines/reference/tsxExternalModuleEmit2.types new file mode 100644 index 00000000000..b4746fe46c7 --- /dev/null +++ b/tests/baselines/reference/tsxExternalModuleEmit2.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/jsx/modules.d.ts === + +declare module 'mod' { + var y: any; +>y : any + + export default y; +>y : any +} + +=== tests/cases/conformance/jsx/app.tsx === +import Main from 'mod'; +>Main : any + +declare var Foo, React; +>Foo : any +>React : any + +// Should see mod_1['default'] in emit here +; +> : any +>Foo : any +>handler : any +>Main : any +>Foo : any + +// Should see mod_1['default'] in emit here +; +> : any +>Foo : any +>Main : any +>Foo : any + + diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols index 8bd68b2e8e7..3bfd5505e76 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols @@ -16,6 +16,7 @@ var T, T1, T2; var x1 = () => {}; >x1 : Symbol(x1, Decl(tsxGenericArrowFunctionParsing.tsx, 7, 3)) >T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) x1.isElement; >x1.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) @@ -44,6 +45,7 @@ var x4 = () => {}; >x4 : Symbol(x4, Decl(tsxGenericArrowFunctionParsing.tsx, 19, 3)) >T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) >extends : Symbol(unknown) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) x4.isElement; >x4.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) @@ -55,6 +57,7 @@ var x5 = () => {}; >x5 : Symbol(x5, Decl(tsxGenericArrowFunctionParsing.tsx, 23, 3)) >T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) >extends : Symbol(unknown) +>T : Symbol(T, Decl(tsxGenericArrowFunctionParsing.tsx, 4, 3)) x5.isElement; >x5.isElement : Symbol(JSX.Element.isElement, Decl(tsxGenericArrowFunctionParsing.tsx, 1, 20)) diff --git a/tests/baselines/reference/tsxInArrowFunction.symbols b/tests/baselines/reference/tsxInArrowFunction.symbols index 814f2577bf0..5896dfa1eef 100644 --- a/tests/baselines/reference/tsxInArrowFunction.symbols +++ b/tests/baselines/reference/tsxInArrowFunction.symbols @@ -24,6 +24,7 @@ declare namespace JSX { >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // didn't work
{x =>
}
; @@ -31,16 +32,20 @@ declare namespace JSX { >x : Symbol(x, Decl(tsxInArrowFunction.tsx, 15, 6)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // worked
{() => (
)}
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // worked (!)
{() =>
}
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) diff --git a/tests/baselines/reference/tsxOpeningClosingNames.symbols b/tests/baselines/reference/tsxOpeningClosingNames.symbols index 3ff2a3ff68d..e9734fb5ee1 100644 --- a/tests/baselines/reference/tsxOpeningClosingNames.symbols +++ b/tests/baselines/reference/tsxOpeningClosingNames.symbols @@ -17,4 +17,5 @@ declare module A.B.C { foo >D : Symbol(unknown) +>D : Symbol(unknown) diff --git a/tests/baselines/reference/tsxParseTests1.symbols b/tests/baselines/reference/tsxParseTests1.symbols index dbe11dbcbba..f7b179f254f 100644 --- a/tests/baselines/reference/tsxParseTests1.symbols +++ b/tests/baselines/reference/tsxParseTests1.symbols @@ -17,4 +17,8 @@ var x =
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) >span : Symbol(JSX.IntrinsicElements.span, Decl(tsxParseTests1.tsx, 2, 35)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxParseTests1.tsx, 2, 35)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests1.tsx, 2, 30)) diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index f1799e5bb77..260bd9cd228 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -69,6 +69,6 @@ var SomeClass = (function () { }; return SomeClass; })(); -var whitespace1 = React.createElement("div", null); -var whitespace2 = React.createElement("div", null, p); +var whitespace1 = React.createElement("div", null, " "); +var whitespace2 = React.createElement("div", null, " ", p, " "); var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index c9e819c82d3..4149142dd82 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -54,22 +54,27 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >y : Symbol(unknown) >b : Symbol(unknown) var openClosed1 =
; >openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed2 =
foo
; >openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; >openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 20, 3)) @@ -77,6 +82,7 @@ var openClosed4 =
{p < p}
; >n : Symbol(unknown) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed5 =
{p > p}
; >openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 21, 3)) @@ -85,6 +91,7 @@ var openClosed5 =
{p > p}
; >b : Symbol(unknown) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) class SomeClass { >SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) @@ -96,6 +103,7 @@ class SomeClass { >rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 25, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var rewrites2 =
{[p, ...p, p]}
; >rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 26, 5)) @@ -103,17 +111,20 @@ class SomeClass { >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var rewrites3 =
{{p}}
; >rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 27, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 27, 25)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var rewrites4 =
this}>
; >rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) >this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var rewrites5 =
; >rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 30, 5)) @@ -122,27 +133,35 @@ class SomeClass { >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var rewrites6 =
; >rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 31, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) >p : Symbol(p, Decl(tsxReactEmit1.tsx, 31, 27)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) } } var whitespace1 =
; >whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 37, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} -
; +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) + +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index 0b6e03c5742..e180d2b6b70 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -47,6 +47,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -54,6 +55,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 9cf739c960c..049fdb1819b 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -23,24 +23,38 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index 1a6ba037230..23910548534 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -8,4 +8,4 @@ declare var Foo, Bar, baz; q s ; //// [tsxReactEmit3.js] -React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); +React.createElement(Foo, null, " ", React.createElement(Bar, null, " q "), " ", React.createElement(Bar, null), " s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols index 857647400a9..042488cf04c 100644 --- a/tests/baselines/reference/tsxReactEmit3.symbols +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -18,4 +18,6 @@ declare var Foo, Bar, baz; >Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) >Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) >Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js new file mode 100644 index 00000000000..f6a7eeb72a1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit5.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [test.d.ts] +export var React; + +//// [react-consumer.tsx] +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; + + +//// [file.js] +//// [react-consumer.js] +var test_1 = require("./test"); +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 = test_1.React.createElement("div", test_1.React.__spread({x: ''}, foo, {y: ''})); diff --git a/tests/baselines/reference/tsxReactEmit5.symbols b/tests/baselines/reference/tsxReactEmit5.symbols new file mode 100644 index 00000000000..388e717957f --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : Symbol(React, Decl(test.d.ts, 0, 10)) + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : Symbol(React, Decl(react-consumer.tsx, 0, 8)) + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) + +var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types new file mode 100644 index 00000000000..fb1c6594f30 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : any + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : any + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : any + +var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any + diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js new file mode 100644 index 00000000000..d20ef7051e0 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit6.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [react-consumer.tsx] +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} + + +//// [file.js] +//// [react-consumer.js] +var M; +(function (M) { +})(M || (M = {})); +var M; +(function (M) { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''})); +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxReactEmit6.symbols b/tests/baselines/reference/tsxReactEmit6.symbols new file mode 100644 index 00000000000..0302cef3e8d --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + export var React: any; +>React : Symbol(React, Decl(react-consumer.tsx, 1, 11)) +} + +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) + + var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>y : Symbol(unknown) +} + diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types new file mode 100644 index 00000000000..1b16b84fcc7 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : typeof M + + export var React: any; +>React : any +} + +namespace M { +>M : typeof M + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : any + + var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any +} + diff --git a/tests/baselines/reference/tsxReactEmitEntities.js b/tests/baselines/reference/tsxReactEmitEntities.js new file mode 100644 index 00000000000..7517c85fc73 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.js @@ -0,0 +1,14 @@ +//// [tsxReactEmitEntities.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; + + +//// [tsxReactEmitEntities.js] +React.createElement("div", null, "Dot goes here: · ¬AnEntity; "); diff --git a/tests/baselines/reference/tsxReactEmitEntities.symbols b/tests/baselines/reference/tsxReactEmitEntities.symbols new file mode 100644 index 00000000000..7de35241a3a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitEntities.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitEntities.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitEntities.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitEntities.tsx, 6, 11)) + +
Dot goes here: · ¬AnEntity;
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxReactEmitEntities.types b/tests/baselines/reference/tsxReactEmitEntities.types new file mode 100644 index 00000000000..e1c9cb6e6bf --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +
Dot goes here: · ¬AnEntity;
; +>
Dot goes here: · ¬AnEntity;
: JSX.Element +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index a124ce73312..a1b5894106f 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -57,17 +57,17 @@ var p = 0; // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; // Emit " " -React.createElement("div", null); +React.createElement("div", null, " "); // Emit " ", p, " " -React.createElement("div", null, p); +React.createElement("div", null, " ", p, " "); // Emit only p React.createElement("div", null, p); // Emit only p React.createElement("div", null, p); // Emit " 3" -React.createElement("div", null, "3"); +React.createElement("div", null, " 3"); // Emit " 3 " -React.createElement("div", null, "3 "); +React.createElement("div", null, " 3 "); // Emit "3" React.createElement("div", null, "3"); // Emit no args diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index 06c8258a2c2..3aa3f0d0f8a 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -24,34 +24,45 @@ var p = 0; // Emit " "
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit " ", p, " "
{p}
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit only p
>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit only p
>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit " 3"
3 >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22))
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit " 3 "
3
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit "3"
@@ -59,12 +70,14 @@ var p = 0; 3
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit no args
>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22))
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit "foo" + ' ' + "bar"
@@ -75,5 +88,6 @@ var p = 0; bar
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 603dc4ca6c1..4622aef1991 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -32,7 +32,7 @@ var p = 0;
{p}
; >
{p}
: JSX.Element >div : any ->p : any +>p : number >div : any // Emit only p @@ -41,7 +41,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any @@ -52,7 +52,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.js b/tests/baselines/reference/tsxReactEmitWhitespace2.js new file mode 100644 index 00000000000..091a193cdc5 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.js @@ -0,0 +1,25 @@ +//// [tsxReactEmitWhitespace2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + + + +//// [tsxReactEmitWhitespace2.js] +// Emit ' word' in the last string +React.createElement("div", null, "word ", React.createElement("code", null, "code"), " word"); +// Same here +React.createElement("div", null, React.createElement("code", null, "code"), " word"); +// And here +React.createElement("div", null, React.createElement("code", null), " word"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.symbols b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols new file mode 100644 index 00000000000..44ff4cba292 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace2.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace2.tsx, 6, 11)) + +// Emit ' word' in the last string +
word code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// Same here +
code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// And here +
word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.types b/tests/baselines/reference/tsxReactEmitWhitespace2.types new file mode 100644 index 00000000000..7287e59b9b1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +// Emit ' word' in the last string +
word code word
; +>
word code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// Same here +
code word
; +>
code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// And here +
word
; +>
word
: JSX.Element +>div : any +> : JSX.Element +>code : any +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols index bfe0c568640..94399b95d1f 100644 --- a/tests/baselines/reference/tsxTypeErrors.symbols +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -18,6 +18,7 @@ var thing = { oops: 100 }; var a3 =
>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) >id : Symbol(unknown) +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types index 92c7148b314..303c7695dbf 100644 --- a/tests/baselines/reference/tsxTypeErrors.types +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -26,7 +26,7 @@ var a3 =
>
: any >div : any >id : any ->thing : any +>thing : { oops: number; } // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/tupleTypeInference.js b/tests/baselines/reference/tupleTypeInference.js new file mode 100644 index 00000000000..dfc0de83022 --- /dev/null +++ b/tests/baselines/reference/tupleTypeInference.js @@ -0,0 +1,31 @@ +//// [tupleTypeInference.ts] +declare var $q: IQService; + +interface IQService { + all(x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; + all(x: [IPromise, IPromise]): IPromise<[T1, T2]>; + all(x: [IPromise]): IPromise<[T1]>; + when(t?: T): IPromise; +} + +interface IPromise { + then(callback: (t: T) => TResult): IPromise; +} + +// Implicit different types +var a = $q.all([$q.when(), $q.when()]); + +// Explicit different types +var b = $q.all([$q.when(), $q.when()]); + +// Implicit identical types +var c = $q.all([$q.when(), $q.when()]); + + +//// [tupleTypeInference.js] +// Implicit different types +var a = $q.all([$q.when(), $q.when()]); +// Explicit different types +var b = $q.all([$q.when(), $q.when()]); +// Implicit identical types +var c = $q.all([$q.when(), $q.when()]); diff --git a/tests/baselines/reference/tupleTypeInference.symbols b/tests/baselines/reference/tupleTypeInference.symbols new file mode 100644 index 00000000000..4dbed73e395 --- /dev/null +++ b/tests/baselines/reference/tupleTypeInference.symbols @@ -0,0 +1,110 @@ +=== tests/cases/compiler/tupleTypeInference.ts === +declare var $q: IQService; +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>IQService : Symbol(IQService, Decl(tupleTypeInference.ts, 0, 26)) + +interface IQService { +>IQService : Symbol(IQService, Decl(tupleTypeInference.ts, 0, 26)) + + all(x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; +>all : Symbol(all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 3, 8)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 3, 11)) +>T3 : Symbol(T3, Decl(tupleTypeInference.ts, 3, 15)) +>x : Symbol(x, Decl(tupleTypeInference.ts, 3, 20)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 3, 8)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 3, 11)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T3 : Symbol(T3, Decl(tupleTypeInference.ts, 3, 15)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 3, 8)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 3, 11)) +>T3 : Symbol(T3, Decl(tupleTypeInference.ts, 3, 15)) + + all(x: [IPromise, IPromise]): IPromise<[T1, T2]>; +>all : Symbol(all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 4, 8)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 4, 11)) +>x : Symbol(x, Decl(tupleTypeInference.ts, 4, 16)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 4, 8)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 4, 11)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 4, 8)) +>T2 : Symbol(T2, Decl(tupleTypeInference.ts, 4, 11)) + + all(x: [IPromise]): IPromise<[T1]>; +>all : Symbol(all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 5, 8)) +>x : Symbol(x, Decl(tupleTypeInference.ts, 5, 12)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 5, 8)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T1 : Symbol(T1, Decl(tupleTypeInference.ts, 5, 8)) + + when(t?: T): IPromise; +>when : Symbol(when, Decl(tupleTypeInference.ts, 5, 47)) +>T : Symbol(T, Decl(tupleTypeInference.ts, 6, 9)) +>t : Symbol(t, Decl(tupleTypeInference.ts, 6, 12)) +>T : Symbol(T, Decl(tupleTypeInference.ts, 6, 9)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T : Symbol(T, Decl(tupleTypeInference.ts, 6, 9)) +} + +interface IPromise { +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>T : Symbol(T, Decl(tupleTypeInference.ts, 9, 19)) + + then(callback: (t: T) => TResult): IPromise; +>then : Symbol(then, Decl(tupleTypeInference.ts, 9, 23)) +>TResult : Symbol(TResult, Decl(tupleTypeInference.ts, 10, 9)) +>callback : Symbol(callback, Decl(tupleTypeInference.ts, 10, 18)) +>t : Symbol(t, Decl(tupleTypeInference.ts, 10, 29)) +>T : Symbol(T, Decl(tupleTypeInference.ts, 9, 19)) +>TResult : Symbol(TResult, Decl(tupleTypeInference.ts, 10, 9)) +>IPromise : Symbol(IPromise, Decl(tupleTypeInference.ts, 7, 1)) +>TResult : Symbol(TResult, Decl(tupleTypeInference.ts, 10, 9)) +} + +// Implicit different types +var a = $q.all([$q.when(), $q.when()]); +>a : Symbol(a, Decl(tupleTypeInference.ts, 14, 3)) +>$q.all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) + +// Explicit different types +var b = $q.all([$q.when(), $q.when()]); +>b : Symbol(b, Decl(tupleTypeInference.ts, 17, 3)) +>$q.all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) + +// Implicit identical types +var c = $q.all([$q.when(), $q.when()]); +>c : Symbol(c, Decl(tupleTypeInference.ts, 20, 3)) +>$q.all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>all : Symbol(IQService.all, Decl(tupleTypeInference.ts, 2, 21), Decl(tupleTypeInference.ts, 3, 91), Decl(tupleTypeInference.ts, 4, 69)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q.when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) +>$q : Symbol($q, Decl(tupleTypeInference.ts, 0, 11)) +>when : Symbol(IQService.when, Decl(tupleTypeInference.ts, 5, 47)) + diff --git a/tests/baselines/reference/tupleTypeInference.types b/tests/baselines/reference/tupleTypeInference.types new file mode 100644 index 00000000000..999574a78e1 --- /dev/null +++ b/tests/baselines/reference/tupleTypeInference.types @@ -0,0 +1,122 @@ +=== tests/cases/compiler/tupleTypeInference.ts === +declare var $q: IQService; +>$q : IQService +>IQService : IQService + +interface IQService { +>IQService : IQService + + all(x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>T1 : T1 +>T2 : T2 +>T3 : T3 +>x : [IPromise, IPromise, IPromise] +>IPromise : IPromise +>T1 : T1 +>IPromise : IPromise +>T2 : T2 +>IPromise : IPromise +>T3 : T3 +>IPromise : IPromise +>T1 : T1 +>T2 : T2 +>T3 : T3 + + all(x: [IPromise, IPromise]): IPromise<[T1, T2]>; +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>T1 : T1 +>T2 : T2 +>x : [IPromise, IPromise] +>IPromise : IPromise +>T1 : T1 +>IPromise : IPromise +>T2 : T2 +>IPromise : IPromise +>T1 : T1 +>T2 : T2 + + all(x: [IPromise]): IPromise<[T1]>; +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>T1 : T1 +>x : [IPromise] +>IPromise : IPromise +>T1 : T1 +>IPromise : IPromise +>T1 : T1 + + when(t?: T): IPromise; +>when : (t?: T) => IPromise +>T : T +>t : T +>T : T +>IPromise : IPromise +>T : T +} + +interface IPromise { +>IPromise : IPromise +>T : T + + then(callback: (t: T) => TResult): IPromise; +>then : (callback: (t: T) => TResult) => IPromise +>TResult : TResult +>callback : (t: T) => TResult +>t : T +>T : T +>TResult : TResult +>IPromise : IPromise +>TResult : TResult +} + +// Implicit different types +var a = $q.all([$q.when(), $q.when()]); +>a : IPromise<[string, number]> +>$q.all([$q.when(), $q.when()]) : IPromise<[string, number]> +>$q.all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>$q : IQService +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>[$q.when(), $q.when()] : [IPromise, IPromise] +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise + +// Explicit different types +var b = $q.all([$q.when(), $q.when()]); +>b : IPromise<[string, number]> +>$q.all([$q.when(), $q.when()]) : IPromise<[string, number]> +>$q.all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>$q : IQService +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>[$q.when(), $q.when()] : [IPromise, IPromise] +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise + +// Implicit identical types +var c = $q.all([$q.when(), $q.when()]); +>c : IPromise<[string, string]> +>$q.all([$q.when(), $q.when()]) : IPromise<[string, string]> +>$q.all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>$q : IQService +>all : { (x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; (x: [IPromise, IPromise]): IPromise<[T1, T2]>; (x: [IPromise]): IPromise<[T1]>; } +>[$q.when(), $q.when()] : [IPromise, IPromise] +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise +>$q.when() : IPromise +>$q.when : (t?: T) => IPromise +>$q : IQService +>when : (t?: T) => IPromise + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.js b/tests/baselines/reference/typeAliasDeclarationEmit.js new file mode 100644 index 00000000000..6e82fe4b07d --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit.js @@ -0,0 +1,14 @@ +//// [typeAliasDeclarationEmit.ts] + +export type callback = () => T; + +export type CallbackArray = () => T; + +//// [typeAliasDeclarationEmit.js] +define(["require", "exports"], function (require, exports) { +}); + + +//// [typeAliasDeclarationEmit.d.ts] +export declare type callback = () => T; +export declare type CallbackArray = () => T; diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.symbols b/tests/baselines/reference/typeAliasDeclarationEmit.symbols new file mode 100644 index 00000000000..5f98ea75a5a --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/typeAliasDeclarationEmit.ts === + +export type callback = () => T; +>callback : Symbol(callback, Decl(typeAliasDeclarationEmit.ts, 0, 0)) +>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 1, 21)) +>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 1, 21)) + +export type CallbackArray = () => T; +>CallbackArray : Symbol(CallbackArray, Decl(typeAliasDeclarationEmit.ts, 1, 34)) +>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 3, 26)) +>callback : Symbol(callback, Decl(typeAliasDeclarationEmit.ts, 0, 0)) +>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 3, 26)) + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.types b/tests/baselines/reference/typeAliasDeclarationEmit.types new file mode 100644 index 00000000000..6f9359e36f5 --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/typeAliasDeclarationEmit.ts === + +export type callback = () => T; +>callback : () => T +>T : T +>T : T + +export type CallbackArray = () => T; +>CallbackArray : () => T +>T : T +>callback : () => T +>T : T + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit2.js b/tests/baselines/reference/typeAliasDeclarationEmit2.js new file mode 100644 index 00000000000..4bb1bd3efd9 --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit2.js @@ -0,0 +1,13 @@ +//// [typeAliasDeclarationEmit2.ts] + +export type A = { value: a }; + +//// [typeAliasDeclarationEmit2.js] +define(["require", "exports"], function (require, exports) { +}); + + +//// [typeAliasDeclarationEmit2.d.ts] +export declare type A = { + value: a; +}; diff --git a/tests/baselines/reference/typeAliasDeclarationEmit2.symbols b/tests/baselines/reference/typeAliasDeclarationEmit2.symbols new file mode 100644 index 00000000000..aebd457d24e --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit2.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/typeAliasDeclarationEmit2.ts === + +export type A = { value: a }; +>A : Symbol(A, Decl(typeAliasDeclarationEmit2.ts, 0, 0)) +>a : Symbol(a, Decl(typeAliasDeclarationEmit2.ts, 1, 14)) +>value : Symbol(value, Decl(typeAliasDeclarationEmit2.ts, 1, 20)) +>a : Symbol(a, Decl(typeAliasDeclarationEmit2.ts, 1, 14)) + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit2.types b/tests/baselines/reference/typeAliasDeclarationEmit2.types new file mode 100644 index 00000000000..bc8bd30935e --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit2.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/typeAliasDeclarationEmit2.ts === + +export type A = { value: a }; +>A : { value: a; } +>a : a +>value : a +>a : a + diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols index abcb8fdfc68..28cb344da6e 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols @@ -3,7 +3,7 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType1.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType1.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols index 86cf8e7cdcd..2287b1db082 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols @@ -3,14 +3,14 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType2.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType2.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) function inner>() { >inner : Symbol(inner, Decl(typeArgumentInferenceApparentType2.ts, 0, 46)) >U : Symbol(U, Decl(typeArgumentInferenceApparentType2.ts, 1, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4369, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) var u: U; diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js new file mode 100644 index 00000000000..e23af7afab6 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js @@ -0,0 +1,13 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols new file mode 100644 index 00000000000..08b61492a54 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) +} + +var nodes: TreeNode[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types new file mode 100644 index 00000000000..ea821607211 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNode[]; +>nodes : { name: string; parent: TreeNode; }[] +>TreeNode : { name: string; parent: TreeNode; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: TreeNode; }[] +>map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: TreeNode; }) => string +>n : { name: string; parent: TreeNode; } +>n.name : string +>n : { name: string; parent: TreeNode; } +>name : string + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js new file mode 100644 index 00000000000..d8e32e12b55 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js @@ -0,0 +1,18 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols new file mode 100644 index 00000000000..cb2e8e94656 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 6, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +var nodes: TreeNodeMiddleman[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types new file mode 100644 index 00000000000..d18cf3a2b1d --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNodeMiddleman[]; +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: { name: string; parent: TreeNode; }; }) => string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>n.name : string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>name : string + diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt b/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt deleted file mode 100644 index 37a662e007c..00000000000 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt +++ /dev/null @@ -1,103 +0,0 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts(93,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts (1 errors) ==== - // In the true expression of a conditional expression, - // the type of a variable or parameter is narrowed by any type guard in the condition when true, - // provided the true expression contains no assignments to the variable or parameter. - // In the false expression of a conditional expression, - // the type of a variable or parameter is narrowed by any type guard in the condition when false, - // provided the false expression contains no assignments to the variable or parameter. - - function foo(x: number | string) { - return typeof x === "string" - ? x.length // string - : x++; // number - } - function foo2(x: number | string) { - // x is assigned in the if true branch, the type is not narrowed - return typeof x === "string" - ? (x = 10 && x)// string | number - : x; // string | number - } - function foo3(x: number | string) { - // x is assigned in the if false branch, the type is not narrowed - // even though assigned using same type as narrowed expression - return typeof x === "string" - ? (x = "Hello" && x) // string | number - : x; // string | number - } - function foo4(x: number | string) { - // false branch updates the variable - so here it is not number - // even though assigned using same type as narrowed expression - return typeof x === "string" - ? x // string | number - : (x = 10 && x); // string | number - } - function foo5(x: number | string) { - // false branch updates the variable - so here it is not number - return typeof x === "string" - ? x // string | number - : (x = "hello" && x); // string | number - } - function foo6(x: number | string) { - // Modify in both branches - return typeof x === "string" - ? (x = 10 && x) // string | number - : (x = "hello" && x); // string | number - } - function foo7(x: number | string | boolean) { - return typeof x === "string" - ? x === "hello" // string - : typeof x === "boolean" - ? x // boolean - : x == 10; // number - } - function foo8(x: number | string | boolean) { - var b: number | boolean; - return typeof x === "string" - ? x === "hello" - : ((b = x) && // number | boolean - (typeof x === "boolean" - ? x // boolean - : x == 10)); // number - } - function foo9(x: number | string) { - var y = 10; - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - return typeof x === "string" - ? ((y = x.length) && x === "hello") // string - : x === 10; // number - } - function foo10(x: number | string | boolean) { - // Mixing typeguards - var b: boolean | number; - return typeof x === "string" - ? x // string - : ((b = x) // x is number | boolean - && typeof x === "number" - && x.toString()); // x is number - } - function foo11(x: number | string | boolean) { - // Mixing typeguards - // Assigning value to x deep inside another guard stops narrowing of type too - var b: number | boolean | string; - return typeof x === "string" - ? x // number | boolean | string - changed in the false branch - : ((b = x) // x is number | boolean | string - because the assignment changed it - && typeof x === "number" - && (x = 10) // assignment to x - && x); // x is number | boolean | string - } - function foo12(x: number | string | boolean) { - // Mixing typeguards - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - var b: number | boolean | string; - return typeof x === "string" - ? (x = 10 && x.toString().length) // number | boolean | string - changed here - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - : ((b = x) // x is number | boolean | string - changed in true branch - && typeof x === "number" - && x); // x is number - } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.symbols b/tests/baselines/reference/typeGuardsInConditionalExpression.symbols new file mode 100644 index 00000000000..ac35c1f18b9 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.symbols @@ -0,0 +1,251 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts === +// In the true expression of a conditional expression, +// the type of a variable or parameter is narrowed by any type guard in the condition when true, +// provided the true expression contains no assignments to the variable or parameter. +// In the false expression of a conditional expression, +// the type of a variable or parameter is narrowed by any type guard in the condition when false, +// provided the false expression contains no assignments to the variable or parameter. + +function foo(x: number | string) { +>foo : Symbol(foo, Decl(typeGuardsInConditionalExpression.ts, 0, 0)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) + + ? x.length // string +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + + : x++; // number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) +} +function foo2(x: number | string) { +>foo2 : Symbol(foo2, Decl(typeGuardsInConditionalExpression.ts, 11, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) + + // x is assigned in the if true branch, the type is not narrowed + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) + + ? (x = 10 && x)// string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) + + : x; // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) +} +function foo3(x: number | string) { +>foo3 : Symbol(foo3, Decl(typeGuardsInConditionalExpression.ts, 17, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) + + // x is assigned in the if false branch, the type is not narrowed + // even though assigned using same type as narrowed expression + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) + + ? (x = "Hello" && x) // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) + + : x; // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) +} +function foo4(x: number | string) { +>foo4 : Symbol(foo4, Decl(typeGuardsInConditionalExpression.ts, 24, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) + + // false branch updates the variable - so here it is not number + // even though assigned using same type as narrowed expression + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) + + ? x // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) + + : (x = 10 && x); // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) +} +function foo5(x: number | string) { +>foo5 : Symbol(foo5, Decl(typeGuardsInConditionalExpression.ts, 31, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) + + // false branch updates the variable - so here it is not number + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) + + ? x // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) + + : (x = "hello" && x); // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) +} +function foo6(x: number | string) { +>foo6 : Symbol(foo6, Decl(typeGuardsInConditionalExpression.ts, 37, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) + + // Modify in both branches + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) + + ? (x = 10 && x) // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) + + : (x = "hello" && x); // string | number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) +} +function foo7(x: number | string | boolean) { +>foo7 : Symbol(foo7, Decl(typeGuardsInConditionalExpression.ts, 43, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) + + ? x === "hello" // string +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) + + : typeof x === "boolean" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) + + ? x // boolean +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) + + : x == 10; // number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) +} +function foo8(x: number | string | boolean) { +>foo8 : Symbol(foo8, Decl(typeGuardsInConditionalExpression.ts, 50, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + var b: number | boolean; +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 52, 7)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + ? x === "hello" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + : ((b = x) && // number | boolean +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 52, 7)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + (typeof x === "boolean" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + ? x // boolean +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) + + : x == 10)); // number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) +} +function foo9(x: number | string) { +>foo9 : Symbol(foo9, Decl(typeGuardsInConditionalExpression.ts, 59, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) + + var y = 10; +>y : Symbol(y, Decl(typeGuardsInConditionalExpression.ts, 61, 7)) + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) + + ? ((y = x.length) && x === "hello") // string +>y : Symbol(y, Decl(typeGuardsInConditionalExpression.ts, 61, 7)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) + + : x === 10; // number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) +} +function foo10(x: number | string | boolean) { +>foo10 : Symbol(foo10, Decl(typeGuardsInConditionalExpression.ts, 66, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) + + // Mixing typeguards + var b: boolean | number; +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 69, 7)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) + + ? x // string +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) + + : ((b = x) // x is number | boolean +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 69, 7)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) + + && typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) + + && x.toString()); // x is number +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +} +function foo11(x: number | string | boolean) { +>foo11 : Symbol(foo11, Decl(typeGuardsInConditionalExpression.ts, 75, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + // Mixing typeguards + // Assigning value to x deep inside another guard stops narrowing of type too + var b: number | boolean | string; +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 79, 7)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + ? x // number | boolean | string - changed in the false branch +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + : ((b = x) // x is number | boolean | string - because the assignment changed it +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 79, 7)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + && typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + && (x = 10) // assignment to x +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) + + && x); // x is number | boolean | string +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) +} +function foo12(x: number | string | boolean) { +>foo12 : Symbol(foo12, Decl(typeGuardsInConditionalExpression.ts, 86, 1)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) + + // Mixing typeguards + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + var b: number | boolean | string; +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 90, 7)) + + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) + + ? (x = 10 && x.toString().length) // number | boolean | string - changed here +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) +>x.toString().length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + + : ((b = x) // x is number | boolean | string - changed in true branch +>b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 90, 7)) +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) + + && typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) + + && x); // x is number +>x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) +} diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types new file mode 100644 index 00000000000..493a8c0a31a --- /dev/null +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -0,0 +1,388 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts === +// In the true expression of a conditional expression, +// the type of a variable or parameter is narrowed by any type guard in the condition when true, +// provided the true expression contains no assignments to the variable or parameter. +// In the false expression of a conditional expression, +// the type of a variable or parameter is narrowed by any type guard in the condition when false, +// provided the false expression contains no assignments to the variable or parameter. + +function foo(x: number | string) { +>foo : (x: number | string) => number +>x : number | string + + return typeof x === "string" +>typeof x === "string" ? x.length // string : x++ : number +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? x.length // string +>x.length : number +>x : string +>length : number + + : x++; // number +>x++ : number +>x : number +} +function foo2(x: number | string) { +>foo2 : (x: number | string) => number | string +>x : number | string + + // x is assigned in the if true branch, the type is not narrowed + return typeof x === "string" +>typeof x === "string" ? (x = 10 && x)// string | number : x : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? (x = 10 && x)// string | number +>(x = 10 && x) : number | string +>x = 10 && x : number | string +>x : number | string +>10 && x : number | string +>10 : number +>x : number | string + + : x; // string | number +>x : number | string +} +function foo3(x: number | string) { +>foo3 : (x: number | string) => number | string +>x : number | string + + // x is assigned in the if false branch, the type is not narrowed + // even though assigned using same type as narrowed expression + return typeof x === "string" +>typeof x === "string" ? (x = "Hello" && x) // string | number : x : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? (x = "Hello" && x) // string | number +>(x = "Hello" && x) : number | string +>x = "Hello" && x : number | string +>x : number | string +>"Hello" && x : number | string +>"Hello" : string +>x : number | string + + : x; // string | number +>x : number | string +} +function foo4(x: number | string) { +>foo4 : (x: number | string) => number | string +>x : number | string + + // false branch updates the variable - so here it is not number + // even though assigned using same type as narrowed expression + return typeof x === "string" +>typeof x === "string" ? x // string | number : (x = 10 && x) : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? x // string | number +>x : number | string + + : (x = 10 && x); // string | number +>(x = 10 && x) : number | string +>x = 10 && x : number | string +>x : number | string +>10 && x : number | string +>10 : number +>x : number | string +} +function foo5(x: number | string) { +>foo5 : (x: number | string) => number | string +>x : number | string + + // false branch updates the variable - so here it is not number + return typeof x === "string" +>typeof x === "string" ? x // string | number : (x = "hello" && x) : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? x // string | number +>x : number | string + + : (x = "hello" && x); // string | number +>(x = "hello" && x) : number | string +>x = "hello" && x : number | string +>x : number | string +>"hello" && x : number | string +>"hello" : string +>x : number | string +} +function foo6(x: number | string) { +>foo6 : (x: number | string) => number | string +>x : number | string + + // Modify in both branches + return typeof x === "string" +>typeof x === "string" ? (x = 10 && x) // string | number : (x = "hello" && x) : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? (x = 10 && x) // string | number +>(x = 10 && x) : number | string +>x = 10 && x : number | string +>x : number | string +>10 && x : number | string +>10 : number +>x : number | string + + : (x = "hello" && x); // string | number +>(x = "hello" && x) : number | string +>x = "hello" && x : number | string +>x : number | string +>"hello" && x : number | string +>"hello" : string +>x : number | string +} +function foo7(x: number | string | boolean) { +>foo7 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + return typeof x === "string" +>typeof x === "string" ? x === "hello" // string : typeof x === "boolean" ? x // boolean : x == 10 : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + ? x === "hello" // string +>x === "hello" : boolean +>x : string +>"hello" : string + + : typeof x === "boolean" +>typeof x === "boolean" ? x // boolean : x == 10 : boolean +>typeof x === "boolean" : boolean +>typeof x : string +>x : number | boolean +>"boolean" : string + + ? x // boolean +>x : boolean + + : x == 10; // number +>x == 10 : boolean +>x : number +>10 : number +} +function foo8(x: number | string | boolean) { +>foo8 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + var b: number | boolean; +>b : number | boolean + + return typeof x === "string" +>typeof x === "string" ? x === "hello" : ((b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10)) : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + ? x === "hello" +>x === "hello" : boolean +>x : string +>"hello" : string + + : ((b = x) && // number | boolean +>((b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10)) : boolean +>(b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10) : boolean +>(b = x) : number | boolean +>b = x : number | boolean +>b : number | boolean +>x : number | boolean + + (typeof x === "boolean" +>(typeof x === "boolean" ? x // boolean : x == 10) : boolean +>typeof x === "boolean" ? x // boolean : x == 10 : boolean +>typeof x === "boolean" : boolean +>typeof x : string +>x : number | boolean +>"boolean" : string + + ? x // boolean +>x : boolean + + : x == 10)); // number +>x == 10 : boolean +>x : number +>10 : number +} +function foo9(x: number | string) { +>foo9 : (x: number | string) => boolean +>x : number | string + + var y = 10; +>y : number +>10 : number + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + return typeof x === "string" +>typeof x === "string" ? ((y = x.length) && x === "hello") // string : x === 10 : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + ? ((y = x.length) && x === "hello") // string +>((y = x.length) && x === "hello") : boolean +>(y = x.length) && x === "hello" : boolean +>(y = x.length) : number +>y = x.length : number +>y : number +>x.length : number +>x : string +>length : number +>x === "hello" : boolean +>x : string +>"hello" : string + + : x === 10; // number +>x === 10 : boolean +>x : number +>10 : number +} +function foo10(x: number | string | boolean) { +>foo10 : (x: number | string | boolean) => string +>x : number | string | boolean + + // Mixing typeguards + var b: boolean | number; +>b : boolean | number + + return typeof x === "string" +>typeof x === "string" ? x // string : ((b = x) // x is number | boolean && typeof x === "number" && x.toString()) : string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + ? x // string +>x : string + + : ((b = x) // x is number | boolean +>((b = x) // x is number | boolean && typeof x === "number" && x.toString()) : string +>(b = x) // x is number | boolean && typeof x === "number" && x.toString() : string +>(b = x) // x is number | boolean && typeof x === "number" : boolean +>(b = x) : number | boolean +>b = x : number | boolean +>b : boolean | number +>x : number | boolean + + && typeof x === "number" +>typeof x === "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + && x.toString()); // x is number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} +function foo11(x: number | string | boolean) { +>foo11 : (x: number | string | boolean) => number | string | boolean +>x : number | string | boolean + + // Mixing typeguards + // Assigning value to x deep inside another guard stops narrowing of type too + var b: number | boolean | string; +>b : number | boolean | string + + return typeof x === "string" +>typeof x === "string" ? x // number | boolean | string - changed in the false branch : ((b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x) : number | string | boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + ? x // number | boolean | string - changed in the false branch +>x : number | string | boolean + + : ((b = x) // x is number | boolean | string - because the assignment changed it +>((b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x) : number | string | boolean +>(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x : number | string | boolean +>(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) : number +>(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" : boolean +>(b = x) : number | string | boolean +>b = x : number | string | boolean +>b : number | boolean | string +>x : number | string | boolean + + && typeof x === "number" +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + && (x = 10) // assignment to x +>(x = 10) : number +>x = 10 : number +>x : number | string | boolean +>10 : number + + && x); // x is number | boolean | string +>x : number | string | boolean +} +function foo12(x: number | string | boolean) { +>foo12 : (x: number | string | boolean) => number +>x : number | string | boolean + + // Mixing typeguards + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + var b: number | boolean | string; +>b : number | boolean | string + + return typeof x === "string" +>typeof x === "string" ? (x = 10 && x.toString().length) // number | boolean | string - changed here : ((b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x) : number +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + ? (x = 10 && x.toString().length) // number | boolean | string - changed here +>(x = 10 && x.toString().length) : number +>x = 10 && x.toString().length : number +>x : number | string | boolean +>10 && x.toString().length : number +>10 : number +>x.toString().length : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string +>length : number + + : ((b = x) // x is number | boolean | string - changed in true branch +>((b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x) : number +>(b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x : number +>(b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" : boolean +>(b = x) : number | string | boolean +>b = x : number | string | boolean +>b : number | boolean | string +>x : number | string | boolean + + && typeof x === "number" +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + && x); // x is number +>x : number +} diff --git a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt deleted file mode 100644 index e675daffd6e..00000000000 --- a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt +++ /dev/null @@ -1,160 +0,0 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(127,23): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(131,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,16): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (3 errors) ==== - // In the true branch statement of an �if� statement, - // the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, - // provided the true branch statement contains no assignments to the variable or parameter. - // In the false branch statement of an �if� statement, - // the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, - // provided the false branch statement contains no assignments to the variable or parameter - function foo(x: number | string) { - if (typeof x === "string") { - return x.length; // string - } - else { - return x++; // number - } - } - function foo2(x: number | string) { - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { - x = 10; - return x; // string | number - } - else { - return x; // string | number - } - } - function foo3(x: number | string) { - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { - x = "Hello"; // even though assigned using same type as narrowed expression - return x; // string | number - } - else { - return x; // string | number - } - } - function foo4(x: number | string) { - // false branch updates the variable - so here it is not number - if (typeof x === "string") { - return x; // string | number - } - else { - x = 10; // even though assigned number - this should result in x to be string | number - return x; // string | number - } - } - function foo5(x: number | string) { - // false branch updates the variable - so here it is not number - if (typeof x === "string") { - return x; // string | number - } - else { - x = "hello"; - return x; // string | number - } - } - function foo6(x: number | string) { - // Modify in both branches - if (typeof x === "string") { - x = 10; - return x; // string | number - } - else { - x = "hello"; - return x; // string | number - } - } - function foo7(x: number | string | boolean) { - if (typeof x === "string") { - return x === "hello"; // string - } - else if (typeof x === "boolean") { - return x; // boolean - } - else { - return x == 10; // number - } - } - function foo8(x: number | string | boolean) { - if (typeof x === "string") { - return x === "hello"; // string - } - else { - var b: number | boolean = x; // number | boolean - if (typeof x === "boolean") { - return x; // boolean - } - else { - return x == 10; // number - } - } - } - function foo9(x: number | string) { - var y = 10; - if (typeof x === "string") { - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - y = x.length; - return x === "hello"; // string - } - else { - return x == 10; // number - } - } - function foo10(x: number | string | boolean) { - // Mixing typeguard narrowing in if statement with conditional expression typeguard - if (typeof x === "string") { - return x === "hello"; // string - } - else { - var y: boolean | string; - var b = x; // number | boolean - return typeof x === "number" - ? x === 10 // number - : x; // x should be boolean - } - } - function foo11(x: number | string | boolean) { - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x deep inside another guard stops narrowing of type too - if (typeof x === "string") { - return x; // string | number | boolean - x changed in else branch - } - else { - var y: number| boolean | string; - var b = x; // number | boolean | string - because below we are changing value of x in if statement - return typeof x === "number" - ? ( - // change value of x - x = 10 && x.toString() // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - ) - : ( - // do not change value - y = x && x.toString() // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - ); - } - } - function foo12(x: number | string | boolean) { - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - if (typeof x === "string") { - return x.toString(); // string | number | boolean - x changed in else branch - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - } - else { - x = 10; - var b = x; // number | boolean | string - return typeof x === "number" - ? x.toString() // number - : x.toString(); // boolean | string - } - } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInIfStatement.js b/tests/baselines/reference/typeGuardsInIfStatement.js index 820d205bc65..de05a7bf82a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.js +++ b/tests/baselines/reference/typeGuardsInIfStatement.js @@ -1,9 +1,9 @@ //// [typeGuardsInIfStatement.ts] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { @@ -149,11 +149,11 @@ function foo12(x: number | string | boolean) { } //// [typeGuardsInIfStatement.js] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x) { if (typeof x === "string") { diff --git a/tests/baselines/reference/typeGuardsInIfStatement.symbols b/tests/baselines/reference/typeGuardsInIfStatement.symbols new file mode 100644 index 00000000000..798fe18cf5a --- /dev/null +++ b/tests/baselines/reference/typeGuardsInIfStatement.symbols @@ -0,0 +1,304 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, +// provided the true branch statement contains no assignments to the variable or parameter. +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, +// provided the false branch statement contains no assignments to the variable or parameter +function foo(x: number | string) { +>foo : Symbol(foo, Decl(typeGuardsInIfStatement.ts, 0, 0)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) + + return x.length; // string +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + } + else { + return x++; // number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) + } +} +function foo2(x: number | string) { +>foo2 : Symbol(foo2, Decl(typeGuardsInIfStatement.ts, 13, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) + + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) + + x = 10; +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) + } + else { + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) + } +} +function foo3(x: number | string) { +>foo3 : Symbol(foo3, Decl(typeGuardsInIfStatement.ts, 23, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) + + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) + + x = "Hello"; // even though assigned using same type as narrowed expression +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) + } + else { + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) + } +} +function foo4(x: number | string) { +>foo4 : Symbol(foo4, Decl(typeGuardsInIfStatement.ts, 33, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) + + // false branch updates the variable - so here it is not number + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) + } + else { + x = 10; // even though assigned number - this should result in x to be string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) + } +} +function foo5(x: number | string) { +>foo5 : Symbol(foo5, Decl(typeGuardsInIfStatement.ts, 43, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) + + // false branch updates the variable - so here it is not number + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) + } + else { + x = "hello"; +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) + } +} +function foo6(x: number | string) { +>foo6 : Symbol(foo6, Decl(typeGuardsInIfStatement.ts, 53, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + + // Modify in both branches + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + + x = 10; +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + } + else { + x = "hello"; +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + + return x; // string | number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) + } +} +function foo7(x: number | string | boolean) { +>foo7 : Symbol(foo7, Decl(typeGuardsInIfStatement.ts, 64, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + + return x === "hello"; // string +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + } + else if (typeof x === "boolean") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + + return x; // boolean +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + } + else { + return x == 10; // number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) + } +} +function foo8(x: number | string | boolean) { +>foo8 : Symbol(foo8, Decl(typeGuardsInIfStatement.ts, 75, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + + return x === "hello"; // string +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + } + else { + var b: number | boolean = x; // number | boolean +>b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 81, 11)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + + if (typeof x === "boolean") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + + return x; // boolean +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + } + else { + return x == 10; // number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) + } + } +} +function foo9(x: number | string) { +>foo9 : Symbol(foo9, Decl(typeGuardsInIfStatement.ts, 89, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) + + var y = 10; +>y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 91, 7)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + y = x.length; +>y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 91, 7)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + + return x === "hello"; // string +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) + } + else { + return x == 10; // number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) + } +} +function foo10(x: number | string | boolean) { +>foo10 : Symbol(foo10, Decl(typeGuardsInIfStatement.ts, 100, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + + return x === "hello"; // string +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + } + else { + var y: boolean | string; +>y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 107, 11)) + + var b = x; // number | boolean +>b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 108, 11)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + + return typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + + ? x === 10 // number +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + + : x; // x should be boolean +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) + } +} +function foo11(x: number | string | boolean) { +>foo11 : Symbol(foo11, Decl(typeGuardsInIfStatement.ts, 113, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x deep inside another guard stops narrowing of type too + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) + + return x; // string | number | boolean - x changed in else branch +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) + } + else { + var y: number| boolean | string; +>y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 121, 11)) + + var b = x; // number | boolean | string - because below we are changing value of x in if statement +>b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 122, 11)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) + + return typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) + + ? ( + // change value of x + x = 10 && x.toString() // number | boolean | string +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + + ) + : ( + // do not change value + y = x && x.toString() // number | boolean | string +>y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 121, 11)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + + ); + } +} +function foo12(x: number | string | boolean) { +>foo12 : Symbol(foo12, Decl(typeGuardsInIfStatement.ts, 133, 1)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) + + return x.toString(); // string | number | boolean - x changed in else branch +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + } + else { + x = 10; +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) + + var b = x; // number | boolean | string +>b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 142, 11)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) + + return typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) + + ? x.toString() // number +>x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) + + : x.toString(); // boolean | string +>x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) +>toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + } +} diff --git a/tests/baselines/reference/typeGuardsInIfStatement.types b/tests/baselines/reference/typeGuardsInIfStatement.types new file mode 100644 index 00000000000..0095a7cc768 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInIfStatement.types @@ -0,0 +1,405 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, +// provided the true branch statement contains no assignments to the variable or parameter. +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, +// provided the false branch statement contains no assignments to the variable or parameter +function foo(x: number | string) { +>foo : (x: number | string) => number +>x : number | string + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + return x.length; // string +>x.length : number +>x : string +>length : number + } + else { + return x++; // number +>x++ : number +>x : number + } +} +function foo2(x: number | string) { +>foo2 : (x: number | string) => number | string +>x : number | string + + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + x = 10; +>x = 10 : number +>x : number | string +>10 : number + + return x; // string | number +>x : number | string + } + else { + return x; // string | number +>x : number | string + } +} +function foo3(x: number | string) { +>foo3 : (x: number | string) => number | string +>x : number | string + + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + x = "Hello"; // even though assigned using same type as narrowed expression +>x = "Hello" : string +>x : number | string +>"Hello" : string + + return x; // string | number +>x : number | string + } + else { + return x; // string | number +>x : number | string + } +} +function foo4(x: number | string) { +>foo4 : (x: number | string) => number | string +>x : number | string + + // false branch updates the variable - so here it is not number + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + return x; // string | number +>x : number | string + } + else { + x = 10; // even though assigned number - this should result in x to be string | number +>x = 10 : number +>x : number | string +>10 : number + + return x; // string | number +>x : number | string + } +} +function foo5(x: number | string) { +>foo5 : (x: number | string) => number | string +>x : number | string + + // false branch updates the variable - so here it is not number + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + return x; // string | number +>x : number | string + } + else { + x = "hello"; +>x = "hello" : string +>x : number | string +>"hello" : string + + return x; // string | number +>x : number | string + } +} +function foo6(x: number | string) { +>foo6 : (x: number | string) => number | string +>x : number | string + + // Modify in both branches + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + x = 10; +>x = 10 : number +>x : number | string +>10 : number + + return x; // string | number +>x : number | string + } + else { + x = "hello"; +>x = "hello" : string +>x : number | string +>"hello" : string + + return x; // string | number +>x : number | string + } +} +function foo7(x: number | string | boolean) { +>foo7 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + return x === "hello"; // string +>x === "hello" : boolean +>x : string +>"hello" : string + } + else if (typeof x === "boolean") { +>typeof x === "boolean" : boolean +>typeof x : string +>x : number | boolean +>"boolean" : string + + return x; // boolean +>x : boolean + } + else { + return x == 10; // number +>x == 10 : boolean +>x : number +>10 : number + } +} +function foo8(x: number | string | boolean) { +>foo8 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + return x === "hello"; // string +>x === "hello" : boolean +>x : string +>"hello" : string + } + else { + var b: number | boolean = x; // number | boolean +>b : number | boolean +>x : number | boolean + + if (typeof x === "boolean") { +>typeof x === "boolean" : boolean +>typeof x : string +>x : number | boolean +>"boolean" : string + + return x; // boolean +>x : boolean + } + else { + return x == 10; // number +>x == 10 : boolean +>x : number +>10 : number + } + } +} +function foo9(x: number | string) { +>foo9 : (x: number | string) => boolean +>x : number | string + + var y = 10; +>y : number +>10 : number + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + y = x.length; +>y = x.length : number +>y : number +>x.length : number +>x : string +>length : number + + return x === "hello"; // string +>x === "hello" : boolean +>x : string +>"hello" : string + } + else { + return x == 10; // number +>x == 10 : boolean +>x : number +>10 : number + } +} +function foo10(x: number | string | boolean) { +>foo10 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + return x === "hello"; // string +>x === "hello" : boolean +>x : string +>"hello" : string + } + else { + var y: boolean | string; +>y : boolean | string + + var b = x; // number | boolean +>b : number | boolean +>x : number | boolean + + return typeof x === "number" +>typeof x === "number" ? x === 10 // number : x : boolean +>typeof x === "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + ? x === 10 // number +>x === 10 : boolean +>x : number +>10 : number + + : x; // x should be boolean +>x : boolean + } +} +function foo11(x: number | string | boolean) { +>foo11 : (x: number | string | boolean) => number | string | boolean +>x : number | string | boolean + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x deep inside another guard stops narrowing of type too + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + return x; // string | number | boolean - x changed in else branch +>x : number | string | boolean + } + else { + var y: number| boolean | string; +>y : number | boolean | string + + var b = x; // number | boolean | string - because below we are changing value of x in if statement +>b : number | string | boolean +>x : number | string | boolean + + return typeof x === "number" +>typeof x === "number" ? ( // change value of x x = 10 && x.toString() // number | boolean | string ) : ( // do not change value y = x && x.toString() // number | boolean | string ) : string +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + ? ( +>( // change value of x x = 10 && x.toString() // number | boolean | string ) : string + + // change value of x + x = 10 && x.toString() // number | boolean | string +>x = 10 && x.toString() : string +>x : number | string | boolean +>10 && x.toString() : string +>10 : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string + + ) + : ( +>( // do not change value y = x && x.toString() // number | boolean | string ) : string + + // do not change value + y = x && x.toString() // number | boolean | string +>y = x && x.toString() : string +>y : number | boolean | string +>x && x.toString() : string +>x : number | string | boolean +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string + + ); + } +} +function foo12(x: number | string | boolean) { +>foo12 : (x: number | string | boolean) => string +>x : number | string | boolean + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + return x.toString(); // string | number | boolean - x changed in else branch +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string + } + else { + x = 10; +>x = 10 : number +>x : number | string | boolean +>10 : number + + var b = x; // number | boolean | string +>b : number | string | boolean +>x : number | string | boolean + + return typeof x === "number" +>typeof x === "number" ? x.toString() // number : x.toString() : string +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + ? x.toString() // number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string + + : x.toString(); // boolean | string +>x.toString() : string +>x.toString : () => string +>x : string | boolean +>toString : () => string + } +} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt deleted file mode 100644 index f44e433a2c8..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt +++ /dev/null @@ -1,64 +0,0 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts(43,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts(45,21): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts (2 errors) ==== - // In the right operand of a && operation, - // the type of a variable or parameter is narrowed by any type guard in the left operand when true, - // provided the right operand contains no assignments to the variable or parameter. - function foo(x: number | string) { - return typeof x === "string" && x.length === 10; // string - } - function foo2(x: number | string) { - // modify x in right hand operand - return typeof x === "string" && ((x = 10) && x); // string | number - } - function foo3(x: number | string) { - // modify x in right hand operand with string type itself - return typeof x === "string" && ((x = "hello") && x); // string | number - } - function foo4(x: number | string | boolean) { - return typeof x !== "string" // string | number | boolean - && typeof x !== "number" // number | boolean - && x; // boolean - } - function foo5(x: number | string | boolean) { - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; - return typeof x !== "string" // string | number | boolean - && ((b = x) && (typeof x !== "number" // number | boolean - && x)); // boolean - } - function foo6(x: number | string | boolean) { - // Mixing typeguard narrowing in if statement with conditional expression typeguard - return typeof x !== "string" // string | number | boolean - && (typeof x !== "number" // number | boolean - ? x // boolean - : x === 10) // number - } - function foo7(x: number | string | boolean) { - var y: number| boolean | string; - var z: number| boolean | string; - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x !== "string" - && ((z = x) // string | number | boolean - x changed deeper in conditional expression - && (typeof x === "number" - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - // do not change value - : (y = x && x.toString()))); // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - } - function foo8(x: number | string) { - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x !== "string" - && (x = 10) // change x - number| string - && (typeof x === "number" - ? x // number - : x.length); // string - } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols new file mode 100644 index 00000000000..59f51d21e71 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols @@ -0,0 +1,143 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts === +// In the right operand of a && operation, +// the type of a variable or parameter is narrowed by any type guard in the left operand when true, +// provided the right operand contains no assignments to the variable or parameter. +function foo(x: number | string) { +>foo : Symbol(foo, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 0, 0)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) + + return typeof x === "string" && x.length === 10; // string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +} +function foo2(x: number | string) { +>foo2 : Symbol(foo2, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 5, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) + + // modify x in right hand operand + return typeof x === "string" && ((x = 10) && x); // string | number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) +} +function foo3(x: number | string) { +>foo3 : Symbol(foo3, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 9, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) + + // modify x in right hand operand with string type itself + return typeof x === "string" && ((x = "hello") && x); // string | number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) +} +function foo4(x: number | string | boolean) { +>foo4 : Symbol(foo4, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 13, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) + + return typeof x !== "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) + + && typeof x !== "number" // number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) + + && x; // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) +} +function foo5(x: number | string | boolean) { +>foo5 : Symbol(foo5, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 18, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; +>b : Symbol(b, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 21, 7)) + + return typeof x !== "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) + + && ((b = x) && (typeof x !== "number" // number | boolean +>b : Symbol(b, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 21, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) + + && x)); // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) +} +function foo6(x: number | string | boolean) { +>foo6 : Symbol(foo6, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 25, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + return typeof x !== "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) + + && (typeof x !== "number" // number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) + + ? x // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) + + : x === 10) // number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) +} +function foo7(x: number | string | boolean) { +>foo7 : Symbol(foo7, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 32, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) + + var y: number| boolean | string; +>y : Symbol(y, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 34, 7)) + + var z: number| boolean | string; +>z : Symbol(z, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 35, 7)) + + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x !== "string" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) + + && ((z = x) // string | number | boolean - x changed deeper in conditional expression +>z : Symbol(z, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 35, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) + + && (typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) + + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + + // do not change value + : (y = x && x.toString()))); // number | boolean | string +>y : Symbol(y, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 34, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +} +function foo8(x: number | string) { +>foo8 : Symbol(foo8, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 45, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) + + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x !== "string" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) + + && (x = 10) // change x - number| string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) + + && (typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) + + ? x // number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) + + : x.length); // string +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types new file mode 100644 index 00000000000..22d390618c1 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -0,0 +1,234 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts === +// In the right operand of a && operation, +// the type of a variable or parameter is narrowed by any type guard in the left operand when true, +// provided the right operand contains no assignments to the variable or parameter. +function foo(x: number | string) { +>foo : (x: number | string) => boolean +>x : number | string + + return typeof x === "string" && x.length === 10; // string +>typeof x === "string" && x.length === 10 : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>x.length === 10 : boolean +>x.length : number +>x : string +>length : number +>10 : number +} +function foo2(x: number | string) { +>foo2 : (x: number | string) => number | string +>x : number | string + + // modify x in right hand operand + return typeof x === "string" && ((x = 10) && x); // string | number +>typeof x === "string" && ((x = 10) && x) : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>((x = 10) && x) : number | string +>(x = 10) && x : number | string +>(x = 10) : number +>x = 10 : number +>x : number | string +>10 : number +>x : number | string +} +function foo3(x: number | string) { +>foo3 : (x: number | string) => number | string +>x : number | string + + // modify x in right hand operand with string type itself + return typeof x === "string" && ((x = "hello") && x); // string | number +>typeof x === "string" && ((x = "hello") && x) : number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>((x = "hello") && x) : number | string +>(x = "hello") && x : number | string +>(x = "hello") : string +>x = "hello" : string +>x : number | string +>"hello" : string +>x : number | string +} +function foo4(x: number | string | boolean) { +>foo4 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + return typeof x !== "string" // string | number | boolean +>typeof x !== "string" // string | number | boolean && typeof x !== "number" // number | boolean && x : boolean +>typeof x !== "string" // string | number | boolean && typeof x !== "number" : boolean +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + && typeof x !== "number" // number | boolean +>typeof x !== "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + && x; // boolean +>x : boolean +} +function foo5(x: number | string | boolean) { +>foo5 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; +>b : number | boolean + + return typeof x !== "string" // string | number | boolean +>typeof x !== "string" // string | number | boolean && ((b = x) && (typeof x !== "number" // number | boolean && x)) : boolean +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + && ((b = x) && (typeof x !== "number" // number | boolean +>((b = x) && (typeof x !== "number" // number | boolean && x)) : boolean +>(b = x) && (typeof x !== "number" // number | boolean && x) : boolean +>(b = x) : number | boolean +>b = x : number | boolean +>b : number | boolean +>x : number | boolean +>(typeof x !== "number" // number | boolean && x) : boolean +>typeof x !== "number" // number | boolean && x : boolean +>typeof x !== "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + && x)); // boolean +>x : boolean +} +function foo6(x: number | string | boolean) { +>foo6 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + // Mixing typeguard narrowing in if statement with conditional expression typeguard + return typeof x !== "string" // string | number | boolean +>typeof x !== "string" // string | number | boolean && (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + && (typeof x !== "number" // number | boolean +>(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean +>typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean +>typeof x !== "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + ? x // boolean +>x : boolean + + : x === 10) // number +>x === 10 : boolean +>x : number +>10 : number +} +function foo7(x: number | string | boolean) { +>foo7 : (x: number | string | boolean) => string +>x : number | string | boolean + + var y: number| boolean | string; +>y : number | boolean | string + + var z: number| boolean | string; +>z : number | boolean | string + + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x !== "string" +>typeof x !== "string" && ((z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + && ((z = x) // string | number | boolean - x changed deeper in conditional expression +>((z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string +>(z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string +>(z = x) : number | string | boolean +>z = x : number | string | boolean +>z : number | boolean | string +>x : number | string | boolean + + && (typeof x === "number" +>(typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string +>typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()) : string +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string +>(x = 10 && x.toString()) : string +>x = 10 && x.toString() : string +>x : number | string | boolean +>10 && x.toString() : string +>10 : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string + + // do not change value + : (y = x && x.toString()))); // number | boolean | string +>(y = x && x.toString()) : string +>y = x && x.toString() : string +>y : number | boolean | string +>x && x.toString() : string +>x : number | string | boolean +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string +} +function foo8(x: number | string) { +>foo8 : (x: number | string) => number +>x : number | string + + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x !== "string" +>typeof x !== "string" && (x = 10) // change x - number| string && (typeof x === "number" ? x // number : x.length) : number +>typeof x !== "string" && (x = 10) : number +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + && (x = 10) // change x - number| string +>(x = 10) : number +>x = 10 : number +>x : number | string +>10 : number + + && (typeof x === "number" +>(typeof x === "number" ? x // number : x.length) : number +>typeof x === "number" ? x // number : x.length : number +>typeof x === "number" : boolean +>typeof x : string +>x : number | string +>"number" : string + + ? x // number +>x : number + + : x.length); // string +>x.length : number +>x : string +>length : number +} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt deleted file mode 100644 index f34d035fa40..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt +++ /dev/null @@ -1,64 +0,0 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts(43,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts(45,21): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts (2 errors) ==== - // In the right operand of a || operation, - // the type of a variable or parameter is narrowed by any type guard in the left operand when false, - // provided the right operand contains no assignments to the variable or parameter. - function foo(x: number | string) { - return typeof x !== "string" || x.length === 10; // string - } - function foo2(x: number | string) { - // modify x in right hand operand - return typeof x !== "string" || ((x = 10) || x); // string | number - } - function foo3(x: number | string) { - // modify x in right hand operand with string type itself - return typeof x !== "string" || ((x = "hello") || x); // string | number - } - function foo4(x: number | string | boolean) { - return typeof x === "string" // string | number | boolean - || typeof x === "number" // number | boolean - || x; // boolean - } - function foo5(x: number | string | boolean) { - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; - return typeof x === "string" // string | number | boolean - || ((b = x) || (typeof x === "number" // number | boolean - || x)); // boolean - } - function foo6(x: number | string | boolean) { - // Mixing typeguard - return typeof x === "string" // string | number | boolean - || (typeof x !== "number" // number | boolean - ? x // boolean - : x === 10) // number - } - function foo7(x: number | string | boolean) { - var y: number| boolean | string; - var z: number| boolean | string; - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x === "string" - || ((z = x) // string | number | boolean - x changed deeper in conditional expression - || (typeof x === "number" - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - // do not change value - : (y = x && x.toString()))); // number | boolean | string - ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - } - function foo8(x: number | string) { - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x === "string" - || (x = 10) // change x - number| string - || (typeof x === "number" - ? x // number - : x.length); // string - } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols new file mode 100644 index 00000000000..d33f0b6877b --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols @@ -0,0 +1,143 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts === +// In the right operand of a || operation, +// the type of a variable or parameter is narrowed by any type guard in the left operand when false, +// provided the right operand contains no assignments to the variable or parameter. +function foo(x: number | string) { +>foo : Symbol(foo, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 0, 0)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) + + return typeof x !== "string" || x.length === 10; // string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +} +function foo2(x: number | string) { +>foo2 : Symbol(foo2, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 5, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) + + // modify x in right hand operand + return typeof x !== "string" || ((x = 10) || x); // string | number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) +} +function foo3(x: number | string) { +>foo3 : Symbol(foo3, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 9, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) + + // modify x in right hand operand with string type itself + return typeof x !== "string" || ((x = "hello") || x); // string | number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) +} +function foo4(x: number | string | boolean) { +>foo4 : Symbol(foo4, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 13, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) + + return typeof x === "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) + + || typeof x === "number" // number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) + + || x; // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) +} +function foo5(x: number | string | boolean) { +>foo5 : Symbol(foo5, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 18, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; +>b : Symbol(b, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 21, 7)) + + return typeof x === "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) + + || ((b = x) || (typeof x === "number" // number | boolean +>b : Symbol(b, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 21, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) + + || x)); // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) +} +function foo6(x: number | string | boolean) { +>foo6 : Symbol(foo6, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 25, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) + + // Mixing typeguard + return typeof x === "string" // string | number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) + + || (typeof x !== "number" // number | boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) + + ? x // boolean +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) + + : x === 10) // number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) +} +function foo7(x: number | string | boolean) { +>foo7 : Symbol(foo7, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 32, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) + + var y: number| boolean | string; +>y : Symbol(y, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 34, 7)) + + var z: number| boolean | string; +>z : Symbol(z, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 35, 7)) + + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) + + || ((z = x) // string | number | boolean - x changed deeper in conditional expression +>z : Symbol(z, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 35, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) + + || (typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) + + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) + + // do not change value + : (y = x && x.toString()))); // number | boolean | string +>y : Symbol(y, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 34, 7)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) +>x.toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) +>toString : Symbol(toString, Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) +} +function foo8(x: number | string) { +>foo8 : Symbol(foo8, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 45, 1)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) + + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x === "string" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) + + || (x = 10) // change x - number| string +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) + + || (typeof x === "number" +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) + + ? x // number +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) + + : x.length); // string +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types new file mode 100644 index 00000000000..38d9a723d3a --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -0,0 +1,234 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts === +// In the right operand of a || operation, +// the type of a variable or parameter is narrowed by any type guard in the left operand when false, +// provided the right operand contains no assignments to the variable or parameter. +function foo(x: number | string) { +>foo : (x: number | string) => boolean +>x : number | string + + return typeof x !== "string" || x.length === 10; // string +>typeof x !== "string" || x.length === 10 : boolean +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>x.length === 10 : boolean +>x.length : number +>x : string +>length : number +>10 : number +} +function foo2(x: number | string) { +>foo2 : (x: number | string) => boolean | number | string +>x : number | string + + // modify x in right hand operand + return typeof x !== "string" || ((x = 10) || x); // string | number +>typeof x !== "string" || ((x = 10) || x) : boolean | number | string +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>((x = 10) || x) : number | string +>(x = 10) || x : number | string +>(x = 10) : number +>x = 10 : number +>x : number | string +>10 : number +>x : number | string +} +function foo3(x: number | string) { +>foo3 : (x: number | string) => boolean | string | number +>x : number | string + + // modify x in right hand operand with string type itself + return typeof x !== "string" || ((x = "hello") || x); // string | number +>typeof x !== "string" || ((x = "hello") || x) : boolean | string | number +>typeof x !== "string" : boolean +>typeof x : string +>x : number | string +>"string" : string +>((x = "hello") || x) : string | number +>(x = "hello") || x : string | number +>(x = "hello") : string +>x = "hello" : string +>x : number | string +>"hello" : string +>x : number | string +} +function foo4(x: number | string | boolean) { +>foo4 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + return typeof x === "string" // string | number | boolean +>typeof x === "string" // string | number | boolean || typeof x === "number" // number | boolean || x : boolean +>typeof x === "string" // string | number | boolean || typeof x === "number" : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + || typeof x === "number" // number | boolean +>typeof x === "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + || x; // boolean +>x : boolean +} +function foo5(x: number | string | boolean) { +>foo5 : (x: number | string | boolean) => boolean | number +>x : number | string | boolean + + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; +>b : number | boolean + + return typeof x === "string" // string | number | boolean +>typeof x === "string" // string | number | boolean || ((b = x) || (typeof x === "number" // number | boolean || x)) : boolean | number +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + || ((b = x) || (typeof x === "number" // number | boolean +>((b = x) || (typeof x === "number" // number | boolean || x)) : number | boolean +>(b = x) || (typeof x === "number" // number | boolean || x) : number | boolean +>(b = x) : number | boolean +>b = x : number | boolean +>b : number | boolean +>x : number | boolean +>(typeof x === "number" // number | boolean || x) : boolean +>typeof x === "number" // number | boolean || x : boolean +>typeof x === "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + || x)); // boolean +>x : boolean +} +function foo6(x: number | string | boolean) { +>foo6 : (x: number | string | boolean) => boolean +>x : number | string | boolean + + // Mixing typeguard + return typeof x === "string" // string | number | boolean +>typeof x === "string" // string | number | boolean || (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + || (typeof x !== "number" // number | boolean +>(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean +>typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean +>typeof x !== "number" : boolean +>typeof x : string +>x : number | boolean +>"number" : string + + ? x // boolean +>x : boolean + + : x === 10) // number +>x === 10 : boolean +>x : number +>10 : number +} +function foo7(x: number | string | boolean) { +>foo7 : (x: number | string | boolean) => boolean | number | string +>x : number | string | boolean + + var y: number| boolean | string; +>y : number | boolean | string + + var z: number| boolean | string; +>z : number | boolean | string + + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x === "string" +>typeof x === "string" || ((z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : boolean | number | string +>typeof x === "string" : boolean +>typeof x : string +>x : number | string | boolean +>"string" : string + + || ((z = x) // string | number | boolean - x changed deeper in conditional expression +>((z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : number | string | boolean +>(z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : number | string | boolean +>(z = x) : number | string | boolean +>z = x : number | string | boolean +>z : number | boolean | string +>x : number | string | boolean + + || (typeof x === "number" +>(typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string +>typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()) : string +>typeof x === "number" : boolean +>typeof x : string +>x : number | string | boolean +>"number" : string + + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string +>(x = 10 && x.toString()) : string +>x = 10 && x.toString() : string +>x : number | string | boolean +>10 && x.toString() : string +>10 : number +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string + + // do not change value + : (y = x && x.toString()))); // number | boolean | string +>(y = x && x.toString()) : string +>y = x && x.toString() : string +>y : number | boolean | string +>x && x.toString() : string +>x : number | string | boolean +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number | string | boolean +>toString : (radix?: number) => string +} +function foo8(x: number | string) { +>foo8 : (x: number | string) => boolean | number +>x : number | string + + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x === "string" +>typeof x === "string" || (x = 10) // change x - number| string || (typeof x === "number" ? x // number : x.length) : boolean | number +>typeof x === "string" || (x = 10) : boolean | number +>typeof x === "string" : boolean +>typeof x : string +>x : number | string +>"string" : string + + || (x = 10) // change x - number| string +>(x = 10) : number +>x = 10 : number +>x : number | string +>10 : number + + || (typeof x === "number" +>(typeof x === "number" ? x // number : x.length) : number +>typeof x === "number" ? x // number : x.length : number +>typeof x === "number" : boolean +>typeof x : string +>x : number | string +>"number" : string + + ? x // number +>x : number + + : x.length); // string +>x.length : number +>x : string +>length : number +} diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index 2f86b6797d7..63b9de2aeda 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -1,18 +1,16 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(12,10): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(34,10): error TS2339: Property 'bar' does not exist on type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(65,10): error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(111,10): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'F | string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'F | string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (12 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (10 errors) ==== interface AConstructor { new (): A; } @@ -84,11 +82,9 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru obj5.foo; obj5.c; obj5.bar1; - ~~~~ -!!! error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. obj5.bar2; ~~~~ -!!! error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. +!!! error TS2339: Property 'bar2' does not exist on type 'C1'. } var obj6: any; @@ -136,11 +132,9 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru if (obj9 instanceof E) { // narrowed to E1 | E2 obj9.foo; obj9.bar1; - ~~~~ -!!! error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. obj9.bar2; ~~~~ -!!! error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. +!!! error TS2339: Property 'bar2' does not exist on type 'E1'. } var obj10: any; diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index b3cc924d419..ab8803e0478 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -16,9 +16,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(24,28): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(25,5): error TS2322: Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(26,5): error TS2322: Type 'V' is not assignable to type 'T'. + Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(27,5): error TS2322: Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(29,5): error TS2322: Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(30,5): error TS2322: Type 'V' is not assignable to type 'U'. + Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(31,5): error TS2322: Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(33,5): error TS2322: Type 'T' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(34,5): error TS2322: Type 'U' is not assignable to type 'V'. @@ -29,9 +31,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(44,44): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(45,5): error TS2322: Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(46,5): error TS2322: Type 'V' is not assignable to type 'T'. + Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(47,5): error TS2322: Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(49,5): error TS2322: Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(50,5): error TS2322: Type 'V' is not assignable to type 'U'. + Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(51,5): error TS2322: Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(53,5): error TS2322: Type 'T' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(54,5): error TS2322: Type 'U' is not assignable to type 'V'. @@ -110,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. @@ -120,6 +125,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. @@ -156,6 +162,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. @@ -166,6 +173,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara u = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Type 'Date' is not assignable to type 'U'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. diff --git a/tests/baselines/reference/typeParameterAssignability3.errors.txt b/tests/baselines/reference/typeParameterAssignability3.errors.txt index 7dbb24ef643..ca7850d747e 100644 --- a/tests/baselines/reference/typeParameterAssignability3.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability3.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(15,5): error TS2322: Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(22,9): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts (4 errors) ==== @@ -21,9 +25,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. } class C { @@ -33,8 +39,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara this.t = this.u; // error ~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'T'. this.u = this.t; // error ~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'Foo' is not assignable to type 'U'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond3.errors.txt b/tests/baselines/reference/typeParameterDiamond3.errors.txt index abefeb2a2d9..14d5e4a313a 100644 --- a/tests/baselines/reference/typeParameterDiamond3.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond3.errors.txt @@ -4,6 +4,9 @@ tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' Type 'Top | T | U' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'U'. + Type 'Bottom' is not assignable to type 'U'. + Type 'Top | T | U' is not assignable to type 'U'. + Type 'Top' is not assignable to type 'U'. tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. Type 'Top | T | U' is not assignable to type 'Top'. Type 'T' is not assignable to type 'Top'. @@ -27,6 +30,9 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom !!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'U'. +!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. +!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. +!!! error TS2322: Type 'Top' is not assignable to type 'U'. top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. diff --git a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt index d86b63d2ce3..d78faf74fab 100644 --- a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt +++ b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint4.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsed tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(4,25): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(5,8): error TS2304: Cannot find name 'W'. tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(8,16): error TS2322: Type 'W' is not assignable to type 'T'. + Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(12,16): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(12,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts(15,8): error TS2304: Cannot find name 'W'. @@ -42,6 +43,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsed return x; ~ !!! error TS2322: Type 'W' is not assignable to type 'T'. +!!! error TS2322: Type 'V' is not assignable to type 'T'. } } diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index 0d9375140ab..27ac1e07eab 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -1,8 +1,11 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'Date' is not assignable to type 'T'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(5,5): error TS2322: Type 'V' is not assignable to type 'T'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(6,5): error TS2322: Type 'T' is not assignable to type 'V'. + Type 'Date' is not assignable to type 'V'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(7,5): error TS2322: Type 'V' is not assignable to type 'U'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(8,5): error TS2322: Type 'U' is not assignable to type 'V'. + Type 'Date' is not assignable to type 'V'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assignable to type 'T'. @@ -13,18 +16,21 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'Date' is not assignable to type 'T'. x = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. z = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. y = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. z = y; // Error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. +!!! error TS2322: Type 'Date' is not assignable to type 'V'. x = zz; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt index 5b1a8e9ae7e..0169f57c06f 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. + Type 'Object' is not assignable to type 'T'. tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. @@ -9,6 +10,7 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type x = y; // Ok ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. +!!! error TS2322: Type 'Object' is not assignable to type 'T'. x = z; // Ok ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. diff --git a/tests/baselines/reference/typeResolution.js.map b/tests/baselines/reference/typeResolution.js.map index 8bbff8aa760..e05b5d65d10 100644 --- a/tests/baselines/reference/typeResolution.js.map +++ b/tests/baselines/reference/typeResolution.js.map @@ -1,2 +1,2 @@ //// [typeResolution.js.map] -{"version":3,"file":"typeResolution.js","sourceRoot":"","sources":["typeResolution.ts"],"names":["TopLevelModule1","TopLevelModule1.SubModule1","TopLevelModule1.SubModule1.SubSubModule1","TopLevelModule1.SubModule1.SubSubModule1.ClassA","TopLevelModule1.SubModule1.SubSubModule1.ClassA.constructor","TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1","TopLevelModule1.SubModule1.SubSubModule1.ClassB","TopLevelModule1.SubModule1.SubSubModule1.ClassB.constructor","TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ","TopLevelModule1.SubModule1.ClassA","TopLevelModule1.SubModule1.ClassA.constructor","TopLevelModule1.SubModule1.ClassA.constructor.AA","TopLevelModule1.SubModule2","TopLevelModule1.SubModule2.SubSubModule2","TopLevelModule1.SubModule2.SubSubModule2.ClassA","TopLevelModule1.SubModule2.SubSubModule2.ClassA.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassA.AisIn1_2_2","TopLevelModule1.SubModule2.SubSubModule2.ClassB","TopLevelModule1.SubModule2.SubSubModule2.ClassB.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassB.BisIn1_2_2","TopLevelModule1.SubModule2.SubSubModule2.ClassC","TopLevelModule1.SubModule2.SubSubModule2.ClassC.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassC.CisIn1_2_2","TopLevelModule1.ClassA","TopLevelModule1.ClassA.constructor","TopLevelModule1.ClassA.AisIn1","TopLevelModule1.NotExportedModule","TopLevelModule1.NotExportedModule.ClassA","TopLevelModule1.NotExportedModule.ClassA.constructor","TopLevelModule2","TopLevelModule2.SubModule3","TopLevelModule2.SubModule3.ClassA","TopLevelModule2.SubModule3.ClassA.constructor","TopLevelModule2.SubModule3.ClassA.AisIn2_3"],"mappings":";IAAA,IAAc,eAAe,CAmG5B;IAnGD,WAAc,eAAe,EAAC,CAAC;QAC3BA,IAAcA,UAAUA,CAwEvBA;QAxEDA,WAAcA,UAAUA,EAACA,CAACA;YACtBC,IAAcA,aAAaA,CAwD1BA;YAxDDA,WAAcA,aAAaA,EAACA,CAACA;gBACzBC;oBAAAC;oBAmBAC,CAACA;oBAlBUD,2BAAUA,GAAjBA;wBAEIE,AADAA,uCAAuCA;4BACnCA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,yCAAyCA;4BACrCA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,qCAAqCA;4BACjCA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,sBAAsBA;4BAClBA,EAAcA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACpCA,IAAIA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;oBACLF,aAACA;gBAADA,CAACA,AAnBDD,IAmBCA;gBAnBYA,oBAAMA,SAmBlBA,CAAAA;gBACDA;oBAAAI;oBAsBAC,CAACA;oBArBUD,2BAAUA,GAAjBA;wBACIE,+CAA+CA;wBAG/CA,AADAA,uCAAuCA;4BACnCA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,yCAAyCA;4BACrCA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,qCAAqCA;4BACjCA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzEA,IAAIA,EAAqCA,CAACA;wBAACA,EAAEA,CAACA,QAAQA,EAAEA,CAACA;wBAGzDA,AADAA,sBAAsBA;4BAClBA,EAAcA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACpCA,IAAIA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;oBACLF,aAACA;gBAADA,CAACA,AAtBDJ,IAsBCA;gBAtBYA,oBAAMA,SAsBlBA,CAAAA;gBAEDA;oBACIO;wBACIC;4BAEIC,AADAA,uCAAuCA;gCACnCA,EAAmDA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACzEA,IAAIA,EAAmDA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACzEA,IAAIA,EAAcA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACpCA,IAAIA,EAAqCA,CAACA;4BAACA,EAAEA,CAACA,QAAQA,EAAEA,CAACA;wBAC7DA,CAACA;oBACLD,CAACA;oBACLD,wBAACA;gBAADA,CAACA,AAVDP,IAUCA;YACLA,CAACA,EAxDaD,aAAaA,GAAbA,wBAAaA,KAAbA,wBAAaA,QAwD1BA;YAGDA,AADAA,0EAA0EA;;gBAEtEW;oBACIC;wBACIC,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAGzEA,AADAA,sBAAsBA;4BAClBA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;gBACLD,CAACA;gBACLD,aAACA;YAADA,CAACA,AAXDX,IAWCA;QACLA,CAACA,EAxEaD,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAwEvBA;QAEDA,IAAcA,UAAUA,CAWvBA;QAXDA,WAAcA,UAAUA,EAACA,CAACA;YACtBe,IAAcA,aAAaA,CAO1BA;YAPDA,WAAcA,aAAaA,EAACA,CAACA;gBAEzBC,AADAA,6DAA6DA;;oBAC7DC;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CD,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;gBAC/CA;oBAAAI;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CJ,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;gBAC/CA;oBAAAO;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CP,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;gBAEZA,JACvCA,CAACA,EAPaD,aAAaA,GAAbA,wBAAaA,KAAbA,wBAAaA,QAO1BA;YAE0CA,JAC/CA,CAACA,EAXaf,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAWvBA;QAEDA;YAAA0B;YAEAC,CAACA;YADUD,uBAAMA,GAAbA,cAAkBE,CAACA;YACvBF,aAACA;QAADA,CAACA,AAFD1B,IAECA;QAMDA,IAAOA,iBAAiBA,CAEvBA;QAFDA,WAAOA,iBAAiBA,EAACA,CAACA;YACtB6B;gBAAAC;gBAAsBC,CAACA;gBAADD,aAACA;YAADA,CAACA,AAAvBD,IAAuBA;YAAVA,wBAAMA,SAAIA,CAAAA;QAC3BA,CAACA,EAFM7B,iBAAiBA,KAAjBA,iBAAiBA,QAEvBA;IACLA,CAACA,EAnGa,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAmG5B;IAED,IAAO,eAAe,CAMrB;IAND,WAAO,eAAe,EAAC,CAAC;QACpBgC,IAAcA,UAAUA,CAIvBA;QAJDA,WAAcA,UAAUA,EAACA,CAACA;YACtBC;gBAAAC;gBAEAC,CAACA;gBADUD,yBAAQA,GAAfA,cAAoBE,CAACA;gBACzBF,aAACA;YAADA,CAACA,AAFDD,IAECA;YAFYA,iBAAMA,SAElBA,CAAAA;QACLA,CAACA,EAJaD,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAIvBA;IACLA,CAACA,EANM,eAAe,KAAf,eAAe,QAMrB"} \ No newline at end of file +{"version":3,"file":"typeResolution.js","sourceRoot":"","sources":["typeResolution.ts"],"names":["TopLevelModule1","TopLevelModule1.SubModule1","TopLevelModule1.SubModule1.SubSubModule1","TopLevelModule1.SubModule1.SubSubModule1.ClassA","TopLevelModule1.SubModule1.SubSubModule1.ClassA.constructor","TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1","TopLevelModule1.SubModule1.SubSubModule1.ClassB","TopLevelModule1.SubModule1.SubSubModule1.ClassB.constructor","TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor","TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ","TopLevelModule1.SubModule1.ClassA","TopLevelModule1.SubModule1.ClassA.constructor","TopLevelModule1.SubModule1.ClassA.constructor.AA","TopLevelModule1.SubModule2","TopLevelModule1.SubModule2.SubSubModule2","TopLevelModule1.SubModule2.SubSubModule2.ClassA","TopLevelModule1.SubModule2.SubSubModule2.ClassA.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassA.AisIn1_2_2","TopLevelModule1.SubModule2.SubSubModule2.ClassB","TopLevelModule1.SubModule2.SubSubModule2.ClassB.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassB.BisIn1_2_2","TopLevelModule1.SubModule2.SubSubModule2.ClassC","TopLevelModule1.SubModule2.SubSubModule2.ClassC.constructor","TopLevelModule1.SubModule2.SubSubModule2.ClassC.CisIn1_2_2","TopLevelModule1.ClassA","TopLevelModule1.ClassA.constructor","TopLevelModule1.ClassA.AisIn1","TopLevelModule1.NotExportedModule","TopLevelModule1.NotExportedModule.ClassA","TopLevelModule1.NotExportedModule.ClassA.constructor","TopLevelModule2","TopLevelModule2.SubModule3","TopLevelModule2.SubModule3.ClassA","TopLevelModule2.SubModule3.ClassA.constructor","TopLevelModule2.SubModule3.ClassA.AisIn2_3"],"mappings":";IAAA,IAAc,eAAe,CAmG5B;IAnGD,WAAc,eAAe,EAAC,CAAC;QAC3BA,IAAcA,UAAUA,CAwEvBA;QAxEDA,WAAcA,UAAUA,EAACA,CAACA;YACtBC,IAAcA,aAAaA,CAwD1BA;YAxDDA,WAAcA,aAAaA,EAACA,CAACA;gBACzBC;oBAAAC;oBAmBAC,CAACA;oBAlBUD,2BAAUA,GAAjBA;wBACIE,uCAAuCA;wBACvCA,IAAIA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,yCAAyCA;wBACzCA,IAAIA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,qCAAqCA;wBACrCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,sBAAsBA;wBACtBA,IAAIA,EAAcA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACpCA,IAAIA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;oBACLF,aAACA;gBAADA,CAACA,AAnBDD,IAmBCA;gBAnBYA,oBAAMA,SAmBlBA,CAAAA;gBACDA;oBAAAI;oBAsBAC,CAACA;oBArBUD,2BAAUA,GAAjBA;wBACIE,+CAA+CA;wBAE/CA,uCAAuCA;wBACvCA,IAAIA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,yCAAyCA;wBACzCA,IAAIA,EAAUA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAChCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,qCAAqCA;wBACrCA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzEA,IAAIA,EAAqCA,CAACA;wBAACA,EAAEA,CAACA,QAAQA,EAAEA,CAACA;wBAEzDA,sBAAsBA;wBACtBA,IAAIA,EAAcA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACpCA,IAAIA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;oBACLF,aAACA;gBAADA,CAACA,AAtBDJ,IAsBCA;gBAtBYA,oBAAMA,SAsBlBA,CAAAA;gBAEDA;oBACIO;wBACIC;4BACIC,uCAAuCA;4BACvCA,IAAIA,EAAmDA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACzEA,IAAIA,EAAmDA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACzEA,IAAIA,EAAcA,CAACA;4BAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;4BACpCA,IAAIA,EAAqCA,CAACA;4BAACA,EAAEA,CAACA,QAAQA,EAAEA,CAACA;wBAC7DA,CAACA;oBACLD,CAACA;oBACLD,wBAACA;gBAADA,CAACA,AAVDP,IAUCA;YACLA,CAACA,EAxDaD,aAAaA,GAAbA,wBAAaA,KAAbA,wBAAaA,QAwD1BA;YAEDA,0EAA0EA;YAC1EA;gBACIW;oBACIC;wBACIC,IAAIA,EAAwBA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAC9CA,IAAIA,EAAmCA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBACzDA,IAAIA,EAAmDA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;wBAEzEA,sBAAsBA;wBACtBA,IAAIA,EAA4BA,CAACA;wBAACA,EAAEA,CAACA,UAAUA,EAAEA,CAACA;oBACtDA,CAACA;gBACLD,CAACA;gBACLD,aAACA;YAADA,CAACA,AAXDX,IAWCA;QACLA,CAACA,EAxEaD,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAwEvBA;QAEDA,IAAcA,UAAUA,CAWvBA;QAXDA,WAAcA,UAAUA,EAACA,CAACA;YACtBe,IAAcA,aAAaA,CAO1BA;YAPDA,WAAcA,aAAaA,EAACA,CAACA;gBACzBC,6DAA6DA;gBAC7DA;oBAAAC;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CD,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;gBAC/CA;oBAAAI;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CJ,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;gBAC/CA;oBAAAO;oBAA8CC,CAACA;oBAAlBD,2BAAUA,GAAjBA,cAAsBE,CAACA;oBAACF,aAACA;gBAADA,CAACA,AAA/CP,IAA+CA;gBAAlCA,oBAAMA,SAA4BA,CAAAA;YAGnDA,CAACA,EAPaD,aAAaA,GAAbA,wBAAaA,KAAbA,wBAAaA,QAO1BA;QAGLA,CAACA,EAXaf,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAWvBA;QAEDA;YAAA0B;YAEAC,CAACA;YADUD,uBAAMA,GAAbA,cAAkBE,CAACA;YACvBF,aAACA;QAADA,CAACA,AAFD1B,IAECA;QAMDA,IAAOA,iBAAiBA,CAEvBA;QAFDA,WAAOA,iBAAiBA,EAACA,CAACA;YACtB6B;gBAAAC;gBAAsBC,CAACA;gBAADD,aAACA;YAADA,CAACA,AAAvBD,IAAuBA;YAAVA,wBAAMA,SAAIA,CAAAA;QAC3BA,CAACA,EAFM7B,iBAAiBA,KAAjBA,iBAAiBA,QAEvBA;IACLA,CAACA,EAnGa,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAmG5B;IAED,IAAO,eAAe,CAMrB;IAND,WAAO,eAAe,EAAC,CAAC;QACpBgC,IAAcA,UAAUA,CAIvBA;QAJDA,WAAcA,UAAUA,EAACA,CAACA;YACtBC;gBAAAC;gBAEAC,CAACA;gBADUD,yBAAQA,GAAfA,cAAoBE,CAACA;gBACzBF,aAACA;YAADA,CAACA,AAFDD,IAECA;YAFYA,iBAAMA,SAElBA,CAAAA;QACLA,CAACA,EAJaD,UAAUA,GAAVA,0BAAUA,KAAVA,0BAAUA,QAIvBA;IACLA,CAACA,EANM,eAAe,KAAf,eAAe,QAMrB"} \ No newline at end of file diff --git a/tests/baselines/reference/typeResolution.sourcemap.txt b/tests/baselines/reference/typeResolution.sourcemap.txt index a7d8bd170f1..244dbed0b92 100644 --- a/tests/baselines/reference/typeResolution.sourcemap.txt +++ b/tests/baselines/reference/typeResolution.sourcemap.txt @@ -390,29 +390,28 @@ sourceFile:typeResolution.ts --- >>> // Try all qualified names of this type 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->public AisIn1_1_1() { - > // Try all qualified names of this type > -2 > -3 > // Try all qualified names of this type -1->Emitted(12, 25) Source(7, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(12, 25) Source(6, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(12, 64) Source(6, 60) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 > // Try all qualified names of this type +1->Emitted(12, 25) Source(6, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(12, 64) Source(6, 60) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> var a1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > a1: ClassA -3 > ; -1 >Emitted(13, 29) Source(7, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(13, 31) Source(7, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(13, 32) Source(7, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) + > +2 > var +3 > a1: ClassA +4 > ; +1 >Emitted(13, 25) Source(7, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(13, 29) Source(7, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +3 >Emitted(13, 31) Source(7, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +4 >Emitted(13, 32) Source(7, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> a1.AisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -545,30 +544,29 @@ sourceFile:typeResolution.ts --- >>> // Two variants of qualifying a peer type 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Two variants of qualifying a peer type > -2 > -3 > // Two variants of qualifying a peer type -1->Emitted(21, 25) Source(13, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(21, 25) Source(12, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(21, 66) Source(12, 62) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 > // Two variants of qualifying a peer type +1->Emitted(21, 25) Source(12, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(21, 66) Source(12, 62) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> var b1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > b1: ClassB -3 > ; -1 >Emitted(22, 29) Source(13, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(22, 31) Source(13, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(22, 32) Source(13, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) + > +2 > var +3 > b1: ClassB +4 > ; +1 >Emitted(22, 25) Source(13, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(22, 29) Source(13, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +3 >Emitted(22, 31) Source(13, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +4 >Emitted(22, 32) Source(13, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> b1.BisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -629,30 +627,29 @@ sourceFile:typeResolution.ts --- >>> // Type only accessible from the root 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Type only accessible from the root > -2 > -3 > // Type only accessible from the root -1->Emitted(26, 25) Source(17, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(26, 25) Source(16, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(26, 62) Source(16, 58) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 > // Type only accessible from the root +1->Emitted(26, 25) Source(16, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(26, 62) Source(16, 58) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> var c1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > c1: TopLevelModule1.SubModule2.SubSubModule2.ClassA -3 > ; -1 >Emitted(27, 29) Source(17, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(27, 31) Source(17, 76) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(27, 32) Source(17, 77) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) + > +2 > var +3 > c1: TopLevelModule1.SubModule2.SubSubModule2.ClassA +4 > ; +1 >Emitted(27, 25) Source(17, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(27, 29) Source(17, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +3 >Emitted(27, 31) Source(17, 76) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +4 >Emitted(27, 32) Source(17, 77) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> c1.AisIn1_2_2(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -677,30 +674,29 @@ sourceFile:typeResolution.ts --- >>> // Interface reference 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Interface reference > -2 > -3 > // Interface reference -1->Emitted(29, 25) Source(20, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(29, 25) Source(19, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(29, 47) Source(19, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 > // Interface reference +1->Emitted(29, 25) Source(19, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(29, 47) Source(19, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> var d1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > d1: InterfaceX -3 > ; -1 >Emitted(30, 29) Source(20, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -2 >Emitted(30, 31) Source(20, 39) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) -3 >Emitted(30, 32) Source(20, 40) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) + > +2 > var +3 > d1: InterfaceX +4 > ; +1 >Emitted(30, 25) Source(20, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +2 >Emitted(30, 29) Source(20, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +3 >Emitted(30, 31) Source(20, 39) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) +4 >Emitted(30, 32) Source(20, 40) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassA.AisIn1_1_1) --- >>> d1.XisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -911,30 +907,29 @@ sourceFile:typeResolution.ts --- >>> // Try all qualified names of this type 1 >^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > > - > // Try all qualified names of this type > -2 > -3 > // Try all qualified names of this type -1 >Emitted(43, 25) Source(29, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(43, 25) Source(28, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(43, 64) Source(28, 60) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 > // Try all qualified names of this type +1 >Emitted(43, 25) Source(28, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(43, 64) Source(28, 60) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> var a1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > a1: ClassA -3 > ; -1 >Emitted(44, 29) Source(29, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(44, 31) Source(29, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(44, 32) Source(29, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) + > +2 > var +3 > a1: ClassA +4 > ; +1 >Emitted(44, 25) Source(29, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(44, 29) Source(29, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +3 >Emitted(44, 31) Source(29, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +4 >Emitted(44, 32) Source(29, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> a1.AisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1067,30 +1062,29 @@ sourceFile:typeResolution.ts --- >>> // Two variants of qualifying a peer type 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Two variants of qualifying a peer type > -2 > -3 > // Two variants of qualifying a peer type -1->Emitted(52, 25) Source(35, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(52, 25) Source(34, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(52, 66) Source(34, 62) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 > // Two variants of qualifying a peer type +1->Emitted(52, 25) Source(34, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(52, 66) Source(34, 62) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> var b1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > b1: ClassB -3 > ; -1 >Emitted(53, 29) Source(35, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(53, 31) Source(35, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(53, 32) Source(35, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) + > +2 > var +3 > b1: ClassB +4 > ; +1 >Emitted(53, 25) Source(35, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(53, 29) Source(35, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +3 >Emitted(53, 31) Source(35, 35) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +4 >Emitted(53, 32) Source(35, 36) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> b1.BisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1151,30 +1145,29 @@ sourceFile:typeResolution.ts --- >>> // Type only accessible from the root 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Type only accessible from the root > -2 > -3 > // Type only accessible from the root -1->Emitted(57, 25) Source(39, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(57, 25) Source(38, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(57, 62) Source(38, 58) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 > // Type only accessible from the root +1->Emitted(57, 25) Source(38, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(57, 62) Source(38, 58) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> var c1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > c1: TopLevelModule1.SubModule2.SubSubModule2.ClassA -3 > ; -1 >Emitted(58, 29) Source(39, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(58, 31) Source(39, 76) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(58, 32) Source(39, 77) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) + > +2 > var +3 > c1: TopLevelModule1.SubModule2.SubSubModule2.ClassA +4 > ; +1 >Emitted(58, 25) Source(39, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(58, 29) Source(39, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +3 >Emitted(58, 31) Source(39, 76) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +4 >Emitted(58, 32) Source(39, 77) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> c1.AisIn1_2_2(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1235,30 +1228,29 @@ sourceFile:typeResolution.ts --- >>> // Interface reference 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Interface reference > -2 > -3 > // Interface reference -1->Emitted(62, 25) Source(43, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(62, 25) Source(42, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(62, 47) Source(42, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 > // Interface reference +1->Emitted(62, 25) Source(42, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(62, 47) Source(42, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> var d1; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > d1: InterfaceX -3 > ; -1 >Emitted(63, 29) Source(43, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -2 >Emitted(63, 31) Source(43, 39) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) -3 >Emitted(63, 32) Source(43, 40) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) + > +2 > var +3 > d1: InterfaceX +4 > ; +1 >Emitted(63, 25) Source(43, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +2 >Emitted(63, 29) Source(43, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +3 >Emitted(63, 31) Source(43, 39) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) +4 >Emitted(63, 32) Source(43, 40) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.ClassB.BisIn1_1_1) --- >>> d1.XisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1433,29 +1425,28 @@ sourceFile:typeResolution.ts --- >>> /* Sampling of stuff from AisIn1_1_1 */ 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->function QQ() { - > /* Sampling of stuff from AisIn1_1_1 */ > -2 > -3 > /* Sampling of stuff from AisIn1_1_1 */ -1->Emitted(74, 29) Source(52, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) -2 >Emitted(74, 29) Source(51, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) -3 >Emitted(74, 68) Source(51, 64) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) +2 > /* Sampling of stuff from AisIn1_1_1 */ +1->Emitted(74, 29) Source(51, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) +2 >Emitted(74, 68) Source(51, 64) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) --- >>> var a4; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > a4: TopLevelModule1.SubModule1.SubSubModule1.ClassA -3 > ; -1 >Emitted(75, 33) Source(52, 29) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) -2 >Emitted(75, 35) Source(52, 80) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) -3 >Emitted(75, 36) Source(52, 81) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) + > +2 > var +3 > a4: TopLevelModule1.SubModule1.SubSubModule1.ClassA +4 > ; +1 >Emitted(75, 29) Source(52, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) +2 >Emitted(75, 33) Source(52, 29) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) +3 >Emitted(75, 35) Source(52, 80) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) +4 >Emitted(75, 36) Source(52, 81) + SourceIndex(0) name (TopLevelModule1.SubModule1.SubSubModule1.NonExportedClassQ.constructor.QQ) --- >>> a4.AisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1726,26 +1717,27 @@ sourceFile:typeResolution.ts --- >>> // Should have no effect on S1.SS1.ClassA above because it is not exported 1 >^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > > - > // Should have no effect on S1.SS1.ClassA above because it is not exported > -2 > -3 > // Should have no effect on S1.SS1.ClassA above because it is not exported -1 >Emitted(88, 13) Source(62, 9) + SourceIndex(0) name (TopLevelModule1.SubModule1) -2 >Emitted(88, 13) Source(61, 9) + SourceIndex(0) name (TopLevelModule1.SubModule1) -3 >Emitted(88, 87) Source(61, 83) + SourceIndex(0) name (TopLevelModule1.SubModule1) +2 > // Should have no effect on S1.SS1.ClassA above because it is not exported +1 >Emitted(88, 13) Source(61, 9) + SourceIndex(0) name (TopLevelModule1.SubModule1) +2 >Emitted(88, 87) Source(61, 83) + SourceIndex(0) name (TopLevelModule1.SubModule1) --- >>> var ClassA = (function () { ->>> function ClassA() { -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^-> +1 >^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - > class ClassA { + > +1 >Emitted(89, 13) Source(62, 9) + SourceIndex(0) name (TopLevelModule1.SubModule1) +--- +>>> function ClassA() { +1->^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^-> +1->class ClassA { > -1 >Emitted(90, 17) Source(63, 13) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA) +1->Emitted(90, 17) Source(63, 13) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA) --- >>> function AA() { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1865,30 +1857,29 @@ sourceFile:typeResolution.ts --- >>> // Interface reference 1->^^^^^^^^^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> > - > // Interface reference > -2 > -3 > // Interface reference -1->Emitted(98, 25) Source(70, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) -2 >Emitted(98, 25) Source(69, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) -3 >Emitted(98, 47) Source(69, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) +2 > // Interface reference +1->Emitted(98, 25) Source(69, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) +2 >Emitted(98, 47) Source(69, 43) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) --- >>> var d2; -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -2 > ^^ -3 > ^ -4 > ^^^^^^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^ +3 > ^^ +4 > ^ +5 > ^^^^^^^^^^-> 1 > - > var -2 > d2: SubSubModule1.InterfaceX -3 > ; -1 >Emitted(99, 29) Source(70, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) -2 >Emitted(99, 31) Source(70, 53) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) -3 >Emitted(99, 32) Source(70, 54) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) + > +2 > var +3 > d2: SubSubModule1.InterfaceX +4 > ; +1 >Emitted(99, 25) Source(70, 21) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) +2 >Emitted(99, 29) Source(70, 25) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) +3 >Emitted(99, 31) Source(70, 53) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) +4 >Emitted(99, 32) Source(70, 54) + SourceIndex(0) name (TopLevelModule1.SubModule1.ClassA.constructor.AA) --- >>> d2.XisIn1_1_1(); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2154,24 +2145,25 @@ sourceFile:typeResolution.ts --- >>> // No code here since these are the mirror of the above calls 1->^^^^^^^^^^^^^^^^ -2 > -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> - > // No code here since these are the mirror of the above calls > -2 > -3 > // No code here since these are the mirror of the above calls -1->Emitted(110, 17) Source(79, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) -2 >Emitted(110, 17) Source(78, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) -3 >Emitted(110, 78) Source(78, 74) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) +2 > // No code here since these are the mirror of the above calls +1->Emitted(110, 17) Source(78, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) +2 >Emitted(110, 78) Source(78, 74) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) --- >>> var ClassA = (function () { ->>> function ClassA() { -1 >^^^^^^^^^^^^^^^^^^^^ -2 > ^^-> +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(112, 21) Source(79, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA) +1 >Emitted(111, 17) Source(79, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) +--- +>>> function ClassA() { +1->^^^^^^^^^^^^^^^^^^^^ +2 > ^^-> +1-> +1->Emitted(112, 21) Source(79, 13) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA) --- >>> } 1->^^^^^^^^^^^^^^^^^^^^ @@ -2390,29 +2382,27 @@ sourceFile:typeResolution.ts 4 >Emitted(131, 47) Source(81, 60) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) --- >>> })(SubSubModule2 = SubModule2.SubSubModule2 || (SubModule2.SubSubModule2 = {})); -1->^^^^^^^^^^^^^^^^ -2 > -3 > ^ -4 > ^^ -5 > ^^^^^^^^^^^^^ -6 > ^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^ -8 > ^^^^^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^ -10> ^^^^^^^^ +1->^^^^^^^^^^^^ +2 > ^ +3 > ^^ +4 > ^^^^^^^^^^^^^ +5 > ^^^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^^^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^^^^^^^ 1-> > export interface InterfaceY { YisIn1_2_2(); } - > interface NonExportedInterfaceQ { } -2 > - > -3 > } -4 > -5 > SubSubModule2 -6 > -7 > SubSubModule2 -8 > -9 > SubSubModule2 -10> { + > interface NonExportedInterfaceQ { } + > +2 > } +3 > +4 > SubSubModule2 +5 > +6 > SubSubModule2 +7 > +8 > SubSubModule2 +9 > { > // No code here since these are the mirror of the above calls > export class ClassA { public AisIn1_2_2() { } } > export class ClassB { public BisIn1_2_2() { } } @@ -2420,41 +2410,38 @@ sourceFile:typeResolution.ts > export interface InterfaceY { YisIn1_2_2(); } > interface NonExportedInterfaceQ { } > } -1->Emitted(132, 17) Source(83, 48) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) -2 >Emitted(132, 13) Source(84, 9) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) -3 >Emitted(132, 14) Source(84, 10) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) -4 >Emitted(132, 16) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) -5 >Emitted(132, 29) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) -6 >Emitted(132, 32) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) -7 >Emitted(132, 56) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) -8 >Emitted(132, 61) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) -9 >Emitted(132, 85) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) -10>Emitted(132, 93) Source(84, 10) + SourceIndex(0) name (TopLevelModule1.SubModule2) +1->Emitted(132, 13) Source(84, 9) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) +2 >Emitted(132, 14) Source(84, 10) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2) +3 >Emitted(132, 16) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) +4 >Emitted(132, 29) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) +5 >Emitted(132, 32) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) +6 >Emitted(132, 56) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) +7 >Emitted(132, 61) Source(77, 23) + SourceIndex(0) name (TopLevelModule1.SubModule2) +8 >Emitted(132, 85) Source(77, 36) + SourceIndex(0) name (TopLevelModule1.SubModule2) +9 >Emitted(132, 93) Source(84, 10) + SourceIndex(0) name (TopLevelModule1.SubModule2) --- >>> })(SubModule2 = TopLevelModule1.SubModule2 || (TopLevelModule1.SubModule2 = {})); -1 >^^^^^^^^^^^^ -2 > -3 > ^ -4 > ^^ -5 > ^^^^^^^^^^ -6 > ^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -8 > ^^^^^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -10> ^^^^^^^^ +1 >^^^^^^^^ +2 > ^ +3 > ^^ +4 > ^^^^^^^^^^ +5 > ^^^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^^^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^^^^^^^ 1 > > - > export interface InterfaceY { YisIn1_2(); } -2 > - > -3 > } -4 > -5 > SubModule2 -6 > -7 > SubModule2 -8 > -9 > SubModule2 -10> { + > export interface InterfaceY { YisIn1_2(); } + > +2 > } +3 > +4 > SubModule2 +5 > +6 > SubModule2 +7 > +8 > SubModule2 +9 > { > export module SubSubModule2 { > // No code here since these are the mirror of the above calls > export class ClassA { public AisIn1_2_2() { } } @@ -2466,16 +2453,15 @@ sourceFile:typeResolution.ts > > export interface InterfaceY { YisIn1_2(); } > } -1 >Emitted(133, 13) Source(86, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2) -2 >Emitted(133, 9) Source(87, 5) + SourceIndex(0) name (TopLevelModule1.SubModule2) -3 >Emitted(133, 10) Source(87, 6) + SourceIndex(0) name (TopLevelModule1.SubModule2) -4 >Emitted(133, 12) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) -5 >Emitted(133, 22) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) -6 >Emitted(133, 25) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) -7 >Emitted(133, 51) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) -8 >Emitted(133, 56) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) -9 >Emitted(133, 82) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) -10>Emitted(133, 90) Source(87, 6) + SourceIndex(0) name (TopLevelModule1) +1 >Emitted(133, 9) Source(87, 5) + SourceIndex(0) name (TopLevelModule1.SubModule2) +2 >Emitted(133, 10) Source(87, 6) + SourceIndex(0) name (TopLevelModule1.SubModule2) +3 >Emitted(133, 12) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) +4 >Emitted(133, 22) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) +5 >Emitted(133, 25) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) +6 >Emitted(133, 51) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) +7 >Emitted(133, 56) Source(76, 19) + SourceIndex(0) name (TopLevelModule1) +8 >Emitted(133, 82) Source(76, 29) + SourceIndex(0) name (TopLevelModule1) +9 >Emitted(133, 90) Source(87, 6) + SourceIndex(0) name (TopLevelModule1) --- >>> var ClassA = (function () { 1 >^^^^^^^^ diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 6b9842f6c81..dcba2e51f48 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4704, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4727, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4736, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4759, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4804, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4831, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4840, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4863, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4872, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4895, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4904, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4927, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4936, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4959, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4968, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 4991, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4768, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4794, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 33ae53f609d..9886982c0f2 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -274,9 +274,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -285,9 +285,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -296,9 +296,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -307,9 +307,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -318,9 +318,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -329,9 +329,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -340,9 +340,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -351,9 +351,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -362,9 +362,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -386,9 +386,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -397,9 +397,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -408,9 +408,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -419,9 +419,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -430,9 +430,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -441,9 +441,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -452,9 +452,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -463,9 +463,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -474,9 +474,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -655,9 +655,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -667,9 +667,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -679,9 +679,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -691,9 +691,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -703,9 +703,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -715,9 +715,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -727,9 +727,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -739,9 +739,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -751,9 +751,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -780,9 +780,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -793,9 +793,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -806,9 +806,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -819,9 +819,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -832,9 +832,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -845,9 +845,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -858,9 +858,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -871,9 +871,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -884,9 +884,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 31b01c5f76e..7fe233c4490 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -547,7 +547,7 @@ _.flatten([1, [2], [3, [[4]]]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number @@ -562,7 +562,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number diff --git a/tests/baselines/reference/unionTypeCallSignatures.errors.txt b/tests/baselines/reference/unionTypeCallSignatures.errors.txt index c25a2bf9f84..ebe38a589ee 100644 --- a/tests/baselines/reference/unionTypeCallSignatures.errors.txt +++ b/tests/baselines/reference/unionTypeCallSignatures.errors.txt @@ -12,29 +12,25 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(30,1): error TS23 tests/cases/conformance/types/union/unionTypeCallSignatures.ts(31,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(36,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(37,12): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(40,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(41,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(42,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(43,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(46,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(47,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(48,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(49,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(40,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(42,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(43,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(47,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(48,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(49,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(55,45): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(56,12): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(59,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(60,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(61,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(62,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(63,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(66,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(67,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(68,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(69,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(59,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(61,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(62,45): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(63,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(67,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(68,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(69,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/conformance/types/union/unionTypeCallSignatures.ts (34 errors) ==== +==== tests/cases/conformance/types/union/unionTypeCallSignatures.ts (30 errors) ==== var numOrDate: number | Date; var strOrBoolean: string | boolean; var strOrNum: string | number; @@ -80,7 +76,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; + var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; unionWithDifferentParameterCount();// no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. @@ -91,7 +87,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; + var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); strOrNum = unionWithOptionalParameter1('hello', 10); strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type @@ -104,30 +100,26 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2 var unionWithOptionalParameter2: { (a: string, b?: number): string; } | { (a: string, b: number): number }; strOrNum = unionWithOptionalParameter2('hello'); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithOptionalParameter2('hello', 10); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. strOrNum = unionWithOptionalParameter2(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; }; - strOrNum = unionWithOptionalParameter3('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + strOrNum = unionWithOptionalParameter3('hello'); strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithOptionalParameter3(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithRestParameter1: { (a: string, ...b: number[]): string; } | { (a: string, ...b: number[]): number }; strOrNum = unionWithRestParameter1('hello'); @@ -143,33 +135,31 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(70,12): error TS2 var unionWithRestParameter2: { (a: string, ...b: number[]): string; } | { (a: string, b: number): number }; strOrNum = unionWithRestParameter2('hello'); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithRestParameter2('hello', 10); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. strOrNum = unionWithRestParameter2('hello', 10, 11); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. strOrNum = unionWithRestParameter2(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number }; - strOrNum = unionWithRestParameter3('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + strOrNum = unionWithRestParameter3('hello'); strOrNum = unionWithRestParameter3('hello', 10); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = unionWithRestParameter3(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2346: Supplied parameters do not match any signature of call target. + + \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeCallSignatures.js b/tests/baselines/reference/unionTypeCallSignatures.js index a4000038ce6..fc3dfc8ebbc 100644 --- a/tests/baselines/reference/unionTypeCallSignatures.js +++ b/tests/baselines/reference/unionTypeCallSignatures.js @@ -26,12 +26,12 @@ unionOfDifferentNumberOfSignatures(); // error - no call signatures unionOfDifferentNumberOfSignatures(10); // error - no call signatures unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures - var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; +var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; unionWithDifferentParameterCount();// no call signature unionWithDifferentParameterCount("hello");// no call signature unionWithDifferentParameterCount("hello", 10);// no call signature - var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; +var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); strOrNum = unionWithOptionalParameter1('hello', 10); strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type @@ -44,7 +44,7 @@ strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signa strOrNum = unionWithOptionalParameter2(); // error no call signature var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; }; -strOrNum = unionWithOptionalParameter3('hello'); // error no call signature +strOrNum = unionWithOptionalParameter3('hello'); strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature strOrNum = unionWithOptionalParameter3(); // error no call signature @@ -64,11 +64,13 @@ strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature strOrNum = unionWithRestParameter2(); // error no call signature var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number }; -strOrNum = unionWithRestParameter3('hello'); // error no call signature +strOrNum = unionWithRestParameter3('hello'); strOrNum = unionWithRestParameter3('hello', 10); // error no call signature strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature -strOrNum = unionWithRestParameter3(); // error no call signature +strOrNum = unionWithRestParameter3(); // error no call signature + + //// [unionTypeCallSignatures.js] var numOrDate; @@ -108,7 +110,7 @@ strOrNum = unionWithOptionalParameter2('hello', 10); // error no call signature strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signature strOrNum = unionWithOptionalParameter2(); // error no call signature var unionWithOptionalParameter3; -strOrNum = unionWithOptionalParameter3('hello'); // error no call signature +strOrNum = unionWithOptionalParameter3('hello'); strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature strOrNum = unionWithOptionalParameter3(); // error no call signature @@ -125,7 +127,7 @@ strOrNum = unionWithRestParameter2('hello', 10, 11); // error no call signature strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature strOrNum = unionWithRestParameter2(); // error no call signature var unionWithRestParameter3; -strOrNum = unionWithRestParameter3('hello'); // error no call signature +strOrNum = unionWithRestParameter3('hello'); strOrNum = unionWithRestParameter3('hello', 10); // error no call signature strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature diff --git a/tests/baselines/reference/unionTypeCallSignatures2.js b/tests/baselines/reference/unionTypeCallSignatures2.js new file mode 100644 index 00000000000..7ec5180972a --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures2.js @@ -0,0 +1,51 @@ +//// [unionTypeCallSignatures2.ts] +interface A { + (x: number): number; + (x: string, y?: string): boolean; + (x: Date): void; + (x: T[]): T[]; +} + +interface B { + (x: number): number; + (x: string): string; + (x: Date): void; + (x: T[]): T[]; +} + +interface C { + (x: string, ...y: string[]): number; + (x: number, s?: string): number; + (x: T[]): T[]; +} + +var f1: A | B | C; +var n1 = f1(42); // number +var s1 = f1("abc"); // boolean | string | number +var a1 = f1([true, false]); // boolean[] + +var f2: C | B | A; +var n2 = f2(42); // number +var s2 = f2("abc"); // number | string | boolean +var a2 = f2([true, false]); // boolean[] + +var f3: B | A | C; +var n3 = f3(42); // number +var s3 = f3("abc"); // string | boolean | number +var a3 = f3([true, false]); // boolean[] + + + +//// [unionTypeCallSignatures2.js] +var f1; +var n1 = f1(42); // number +var s1 = f1("abc"); // boolean | string | number +var a1 = f1([true, false]); // boolean[] +var f2; +var n2 = f2(42); // number +var s2 = f2("abc"); // number | string | boolean +var a2 = f2([true, false]); // boolean[] +var f3; +var n3 = f3(42); // number +var s3 = f3("abc"); // string | boolean | number +var a3 = f3([true, false]); // boolean[] diff --git a/tests/baselines/reference/unionTypeCallSignatures2.symbols b/tests/baselines/reference/unionTypeCallSignatures2.symbols new file mode 100644 index 00000000000..35ba9464df0 --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures2.symbols @@ -0,0 +1,115 @@ +=== tests/cases/conformance/types/union/unionTypeCallSignatures2.ts === +interface A { +>A : Symbol(A, Decl(unionTypeCallSignatures2.ts, 0, 0)) + + (x: number): number; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 1, 5)) + + (x: string, y?: string): boolean; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 2, 5)) +>y : Symbol(y, Decl(unionTypeCallSignatures2.ts, 2, 15)) + + (x: Date): void; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 3, 5)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + (x: T[]): T[]; +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 4, 5)) +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 4, 8)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 4, 5)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 4, 5)) +} + +interface B { +>B : Symbol(B, Decl(unionTypeCallSignatures2.ts, 5, 1)) + + (x: number): number; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 8, 5)) + + (x: string): string; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 9, 5)) + + (x: Date): void; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 10, 5)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + (x: T[]): T[]; +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 11, 5)) +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 11, 8)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 11, 5)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 11, 5)) +} + +interface C { +>C : Symbol(C, Decl(unionTypeCallSignatures2.ts, 12, 1)) + + (x: string, ...y: string[]): number; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 15, 5)) +>y : Symbol(y, Decl(unionTypeCallSignatures2.ts, 15, 15)) + + (x: number, s?: string): number; +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 16, 5)) +>s : Symbol(s, Decl(unionTypeCallSignatures2.ts, 16, 15)) + + (x: T[]): T[]; +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 17, 5)) +>x : Symbol(x, Decl(unionTypeCallSignatures2.ts, 17, 8)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 17, 5)) +>T : Symbol(T, Decl(unionTypeCallSignatures2.ts, 17, 5)) +} + +var f1: A | B | C; +>f1 : Symbol(f1, Decl(unionTypeCallSignatures2.ts, 20, 3)) +>A : Symbol(A, Decl(unionTypeCallSignatures2.ts, 0, 0)) +>B : Symbol(B, Decl(unionTypeCallSignatures2.ts, 5, 1)) +>C : Symbol(C, Decl(unionTypeCallSignatures2.ts, 12, 1)) + +var n1 = f1(42); // number +>n1 : Symbol(n1, Decl(unionTypeCallSignatures2.ts, 21, 3)) +>f1 : Symbol(f1, Decl(unionTypeCallSignatures2.ts, 20, 3)) + +var s1 = f1("abc"); // boolean | string | number +>s1 : Symbol(s1, Decl(unionTypeCallSignatures2.ts, 22, 3)) +>f1 : Symbol(f1, Decl(unionTypeCallSignatures2.ts, 20, 3)) + +var a1 = f1([true, false]); // boolean[] +>a1 : Symbol(a1, Decl(unionTypeCallSignatures2.ts, 23, 3)) +>f1 : Symbol(f1, Decl(unionTypeCallSignatures2.ts, 20, 3)) + +var f2: C | B | A; +>f2 : Symbol(f2, Decl(unionTypeCallSignatures2.ts, 25, 3)) +>C : Symbol(C, Decl(unionTypeCallSignatures2.ts, 12, 1)) +>B : Symbol(B, Decl(unionTypeCallSignatures2.ts, 5, 1)) +>A : Symbol(A, Decl(unionTypeCallSignatures2.ts, 0, 0)) + +var n2 = f2(42); // number +>n2 : Symbol(n2, Decl(unionTypeCallSignatures2.ts, 26, 3)) +>f2 : Symbol(f2, Decl(unionTypeCallSignatures2.ts, 25, 3)) + +var s2 = f2("abc"); // number | string | boolean +>s2 : Symbol(s2, Decl(unionTypeCallSignatures2.ts, 27, 3)) +>f2 : Symbol(f2, Decl(unionTypeCallSignatures2.ts, 25, 3)) + +var a2 = f2([true, false]); // boolean[] +>a2 : Symbol(a2, Decl(unionTypeCallSignatures2.ts, 28, 3)) +>f2 : Symbol(f2, Decl(unionTypeCallSignatures2.ts, 25, 3)) + +var f3: B | A | C; +>f3 : Symbol(f3, Decl(unionTypeCallSignatures2.ts, 30, 3)) +>B : Symbol(B, Decl(unionTypeCallSignatures2.ts, 5, 1)) +>A : Symbol(A, Decl(unionTypeCallSignatures2.ts, 0, 0)) +>C : Symbol(C, Decl(unionTypeCallSignatures2.ts, 12, 1)) + +var n3 = f3(42); // number +>n3 : Symbol(n3, Decl(unionTypeCallSignatures2.ts, 31, 3)) +>f3 : Symbol(f3, Decl(unionTypeCallSignatures2.ts, 30, 3)) + +var s3 = f3("abc"); // string | boolean | number +>s3 : Symbol(s3, Decl(unionTypeCallSignatures2.ts, 32, 3)) +>f3 : Symbol(f3, Decl(unionTypeCallSignatures2.ts, 30, 3)) + +var a3 = f3([true, false]); // boolean[] +>a3 : Symbol(a3, Decl(unionTypeCallSignatures2.ts, 33, 3)) +>f3 : Symbol(f3, Decl(unionTypeCallSignatures2.ts, 30, 3)) + + diff --git a/tests/baselines/reference/unionTypeCallSignatures2.types b/tests/baselines/reference/unionTypeCallSignatures2.types new file mode 100644 index 00000000000..64295c1b452 --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures2.types @@ -0,0 +1,139 @@ +=== tests/cases/conformance/types/union/unionTypeCallSignatures2.ts === +interface A { +>A : A + + (x: number): number; +>x : number + + (x: string, y?: string): boolean; +>x : string +>y : string + + (x: Date): void; +>x : Date +>Date : Date + + (x: T[]): T[]; +>T : T +>x : T[] +>T : T +>T : T +} + +interface B { +>B : B + + (x: number): number; +>x : number + + (x: string): string; +>x : string + + (x: Date): void; +>x : Date +>Date : Date + + (x: T[]): T[]; +>T : T +>x : T[] +>T : T +>T : T +} + +interface C { +>C : C + + (x: string, ...y: string[]): number; +>x : string +>y : string[] + + (x: number, s?: string): number; +>x : number +>s : string + + (x: T[]): T[]; +>T : T +>x : T[] +>T : T +>T : T +} + +var f1: A | B | C; +>f1 : A | B | C +>A : A +>B : B +>C : C + +var n1 = f1(42); // number +>n1 : number +>f1(42) : number +>f1 : A | B | C +>42 : number + +var s1 = f1("abc"); // boolean | string | number +>s1 : boolean | string | number +>f1("abc") : boolean | string | number +>f1 : A | B | C +>"abc" : string + +var a1 = f1([true, false]); // boolean[] +>a1 : boolean[] +>f1([true, false]) : boolean[] +>f1 : A | B | C +>[true, false] : boolean[] +>true : boolean +>false : boolean + +var f2: C | B | A; +>f2 : C | B | A +>C : C +>B : B +>A : A + +var n2 = f2(42); // number +>n2 : number +>f2(42) : number +>f2 : C | B | A +>42 : number + +var s2 = f2("abc"); // number | string | boolean +>s2 : number | string | boolean +>f2("abc") : number | string | boolean +>f2 : C | B | A +>"abc" : string + +var a2 = f2([true, false]); // boolean[] +>a2 : boolean[] +>f2([true, false]) : boolean[] +>f2 : C | B | A +>[true, false] : boolean[] +>true : boolean +>false : boolean + +var f3: B | A | C; +>f3 : B | A | C +>B : B +>A : A +>C : C + +var n3 = f3(42); // number +>n3 : number +>f3(42) : number +>f3 : B | A | C +>42 : number + +var s3 = f3("abc"); // string | boolean | number +>s3 : string | boolean | number +>f3("abc") : string | boolean | number +>f3 : B | A | C +>"abc" : string + +var a3 = f3([true, false]); // boolean[] +>a3 : boolean[] +>f3([true, false]) : boolean[] +>f3 : B | A | C +>[true, false] : boolean[] +>true : boolean +>false : boolean + + diff --git a/tests/baselines/reference/unionTypeCallSignatures3.js b/tests/baselines/reference/unionTypeCallSignatures3.js new file mode 100644 index 00000000000..2dae152e474 --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures3.js @@ -0,0 +1,39 @@ +//// [unionTypeCallSignatures3.ts] +function f1(s: string) { } +function f2(s?: string) { } +function f3(...s: string[]) { } +function f4(s: string, s2?: string) { } +function f5(s?: string, n?: number) { } +function f6(s?: string, ...n: number[]) { } +function f7(s: string, ...sRest: string[]) { } + +var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7; + +fUnion(""); // All constituents can be called by passing a single string. + + +//// [unionTypeCallSignatures3.js] +function f1(s) { } +function f2(s) { } +function f3() { + var s = []; + for (var _i = 0; _i < arguments.length; _i++) { + s[_i - 0] = arguments[_i]; + } +} +function f4(s, s2) { } +function f5(s, n) { } +function f6(s) { + var n = []; + for (var _i = 1; _i < arguments.length; _i++) { + n[_i - 1] = arguments[_i]; + } +} +function f7(s) { + var sRest = []; + for (var _i = 1; _i < arguments.length; _i++) { + sRest[_i - 1] = arguments[_i]; + } +} +var fUnion; +fUnion(""); // All constituents can be called by passing a single string. diff --git a/tests/baselines/reference/unionTypeCallSignatures3.symbols b/tests/baselines/reference/unionTypeCallSignatures3.symbols new file mode 100644 index 00000000000..45dffe2d821 --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures3.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/types/union/unionTypeCallSignatures3.ts === +function f1(s: string) { } +>f1 : Symbol(f1, Decl(unionTypeCallSignatures3.ts, 0, 0)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 0, 12)) + +function f2(s?: string) { } +>f2 : Symbol(f2, Decl(unionTypeCallSignatures3.ts, 0, 26)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 1, 12)) + +function f3(...s: string[]) { } +>f3 : Symbol(f3, Decl(unionTypeCallSignatures3.ts, 1, 27)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 2, 12)) + +function f4(s: string, s2?: string) { } +>f4 : Symbol(f4, Decl(unionTypeCallSignatures3.ts, 2, 31)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 3, 12)) +>s2 : Symbol(s2, Decl(unionTypeCallSignatures3.ts, 3, 22)) + +function f5(s?: string, n?: number) { } +>f5 : Symbol(f5, Decl(unionTypeCallSignatures3.ts, 3, 39)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 4, 12)) +>n : Symbol(n, Decl(unionTypeCallSignatures3.ts, 4, 23)) + +function f6(s?: string, ...n: number[]) { } +>f6 : Symbol(f6, Decl(unionTypeCallSignatures3.ts, 4, 39)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 5, 12)) +>n : Symbol(n, Decl(unionTypeCallSignatures3.ts, 5, 23)) + +function f7(s: string, ...sRest: string[]) { } +>f7 : Symbol(f7, Decl(unionTypeCallSignatures3.ts, 5, 43)) +>s : Symbol(s, Decl(unionTypeCallSignatures3.ts, 6, 12)) +>sRest : Symbol(sRest, Decl(unionTypeCallSignatures3.ts, 6, 22)) + +var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7; +>fUnion : Symbol(fUnion, Decl(unionTypeCallSignatures3.ts, 8, 3)) +>f1 : Symbol(f1, Decl(unionTypeCallSignatures3.ts, 0, 0)) +>f2 : Symbol(f2, Decl(unionTypeCallSignatures3.ts, 0, 26)) +>f3 : Symbol(f3, Decl(unionTypeCallSignatures3.ts, 1, 27)) +>f4 : Symbol(f4, Decl(unionTypeCallSignatures3.ts, 2, 31)) +>f5 : Symbol(f5, Decl(unionTypeCallSignatures3.ts, 3, 39)) +>f6 : Symbol(f6, Decl(unionTypeCallSignatures3.ts, 4, 39)) +>f7 : Symbol(f7, Decl(unionTypeCallSignatures3.ts, 5, 43)) + +fUnion(""); // All constituents can be called by passing a single string. +>fUnion : Symbol(fUnion, Decl(unionTypeCallSignatures3.ts, 8, 3)) + diff --git a/tests/baselines/reference/unionTypeCallSignatures3.types b/tests/baselines/reference/unionTypeCallSignatures3.types new file mode 100644 index 00000000000..52aae993e4a --- /dev/null +++ b/tests/baselines/reference/unionTypeCallSignatures3.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/types/union/unionTypeCallSignatures3.ts === +function f1(s: string) { } +>f1 : (s: string) => void +>s : string + +function f2(s?: string) { } +>f2 : (s?: string) => void +>s : string + +function f3(...s: string[]) { } +>f3 : (...s: string[]) => void +>s : string[] + +function f4(s: string, s2?: string) { } +>f4 : (s: string, s2?: string) => void +>s : string +>s2 : string + +function f5(s?: string, n?: number) { } +>f5 : (s?: string, n?: number) => void +>s : string +>n : number + +function f6(s?: string, ...n: number[]) { } +>f6 : (s?: string, ...n: number[]) => void +>s : string +>n : number[] + +function f7(s: string, ...sRest: string[]) { } +>f7 : (s: string, ...sRest: string[]) => void +>s : string +>sRest : string[] + +var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7; +>fUnion : ((s: string) => void) | ((s?: string) => void) | ((...s: string[]) => void) | ((s: string, s2?: string) => void) | ((s?: string, n?: number) => void) | ((s?: string, ...n: number[]) => void) | ((s: string, ...sRest: string[]) => void) +>f1 : (s: string) => void +>f2 : (s?: string) => void +>f3 : (...s: string[]) => void +>f4 : (s: string, s2?: string) => void +>f5 : (s?: string, n?: number) => void +>f6 : (s?: string, ...n: number[]) => void +>f7 : (s: string, ...sRest: string[]) => void + +fUnion(""); // All constituents can be called by passing a single string. +>fUnion("") : void +>fUnion : ((s: string) => void) | ((s?: string) => void) | ((...s: string[]) => void) | ((s: string, s2?: string) => void) | ((s?: string, n?: number) => void) | ((s?: string, ...n: number[]) => void) | ((s: string, ...sRest: string[]) => void) +>"" : string + diff --git a/tests/baselines/reference/unionTypeConstructSignatures.errors.txt b/tests/baselines/reference/unionTypeConstructSignatures.errors.txt index cbdcc9ed12a..0332aa61110 100644 --- a/tests/baselines/reference/unionTypeConstructSignatures.errors.txt +++ b/tests/baselines/reference/unionTypeConstructSignatures.errors.txt @@ -12,29 +12,25 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(30,1): error tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(31,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(36,53): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(37,12): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(40,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(41,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(42,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(43,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(46,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(47,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(48,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(49,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(40,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(42,53): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(43,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(47,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(48,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(49,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(55,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(56,12): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(59,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(60,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(61,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(62,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(63,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(66,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(67,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(68,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(69,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(59,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(61,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(62,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(63,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(67,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(68,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(69,12): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/conformance/types/union/unionTypeConstructSignatures.ts (34 errors) ==== +==== tests/cases/conformance/types/union/unionTypeConstructSignatures.ts (30 errors) ==== var numOrDate: number | Date; var strOrBoolean: string | boolean; var strOrNum: string | number; @@ -104,30 +100,26 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): erro var unionWithOptionalParameter2: { new (a: string, b?: number): string; } | { new (a: string, b: number): number }; strOrNum = new unionWithOptionalParameter2('hello'); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithOptionalParameter2('hello', 10); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. strOrNum = new unionWithOptionalParameter2('hello', "hello"); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. strOrNum = new unionWithOptionalParameter2(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithOptionalParameter3: { new (a: string, b?: number): string; } | { new (a: string): number; }; strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. strOrNum = new unionWithOptionalParameter3('hello', 10); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithOptionalParameter3('hello', "hello"); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithOptionalParameter3(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithRestParameter1: { new (a: string, ...b: number[]): string; } | { new (a: string, ...b: number[]): number }; strOrNum = new unionWithRestParameter1('hello'); @@ -143,33 +135,29 @@ tests/cases/conformance/types/union/unionTypeConstructSignatures.ts(70,12): erro var unionWithRestParameter2: { new (a: string, ...b: number[]): string; } | { new (a: string, b: number): number }; strOrNum = new unionWithRestParameter2('hello'); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithRestParameter2('hello', 10); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. strOrNum = new unionWithRestParameter2('hello', 10, 11); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithRestParameter2('hello', "hello"); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + ~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. strOrNum = new unionWithRestParameter2(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. var unionWithRestParameter3: { new (a: string, ...b: number[]): string; } | { new (a: string): number }; strOrNum = new unionWithRestParameter3('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. strOrNum = new unionWithRestParameter3('hello', 10); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithRestParameter3('hello', 10, 11); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithRestParameter3('hello', "hello"); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +!!! error TS2346: Supplied parameters do not match any signature of call target. strOrNum = new unionWithRestParameter3(); // error no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.types b/tests/baselines/reference/unionTypeFromArrayLiteral.types index 604925eb25f..63aefdd214c 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.types +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.types @@ -83,15 +83,15 @@ var arr6 = [c, d]; // (C | D)[] >d : D var arr7 = [c, d, e]; // (C | D)[] ->arr7 : (C | D | E)[] ->[c, d, e] : (C | D | E)[] +>arr7 : (C | D)[] +>[c, d, e] : (C | D)[] >c : C >d : D >e : E var arr8 = [c, e]; // C[] ->arr8 : (C | E)[] ->[c, e] : (C | E)[] +>arr8 : C[] +>[c, e] : C[] >c : C >e : E diff --git a/tests/baselines/reference/unionTypeReduction.types b/tests/baselines/reference/unionTypeReduction.types index 8ecd9b33fb5..073d690162a 100644 --- a/tests/baselines/reference/unionTypeReduction.types +++ b/tests/baselines/reference/unionTypeReduction.types @@ -25,8 +25,8 @@ var e1: I2 | I3; >I3 : I3 var e2 = i2 || i3; // Type of e2 immediately reduced to I3 ->e2 : I2 | I3 ->i2 || i3 : I2 | I3 +>e2 : I3 +>i2 || i3 : I3 >i2 : I2 >i3 : I3 @@ -38,5 +38,5 @@ var r1 = e1(); // Type of e1 reduced to I3 upon accessing property or signature var r2 = e2(); >r2 : number >e2() : number ->e2 : I2 | I3 +>e2 : I3 diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types index f609301c19c..caaa02b7b53 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types @@ -39,7 +39,7 @@ var t: Class | Property; >Property : Property t.parent; ->t.parent : Namespace | Module | Class +>t.parent : Namespace | Class >t : Class | Property ->parent : Namespace | Module | Class +>parent : Namespace | Class diff --git a/tests/cases/compiler/assignmentCompat1.ts b/tests/cases/compiler/assignmentCompat1.ts index 552cdb7de0e..b37a11b20d9 100644 --- a/tests/cases/compiler/assignmentCompat1.ts +++ b/tests/cases/compiler/assignmentCompat1.ts @@ -1,5 +1,7 @@ -var x = {one: 1}; -var y: {[index:string]: any}; - -x = y; -y = x; \ No newline at end of file +var x = { one: 1 }; +var y: { [index: string]: any }; +var z: { [index: number]: any }; +x = y; // Error +y = x; // Ok because index signature type is any +x = z; // Error +z = x; // Ok because index signature type is any diff --git a/tests/cases/compiler/assignmentNonObjectTypeConstraints.ts b/tests/cases/compiler/assignmentNonObjectTypeConstraints.ts new file mode 100644 index 00000000000..b68fad48e8e --- /dev/null +++ b/tests/cases/compiler/assignmentNonObjectTypeConstraints.ts @@ -0,0 +1,18 @@ +const enum E { A, B, C } + +function foo(x: T) { + var y: number = x; // Ok +} + +foo(5); +foo(E.A); + +class A { a } +class B { b } + +function bar(x: T) { + var y: A | B = x; // Ok +} + +bar(new A); +bar(new B); diff --git a/tests/cases/compiler/classExtendsNull.ts b/tests/cases/compiler/classExtendsNull.ts new file mode 100644 index 00000000000..5532fa72702 --- /dev/null +++ b/tests/cases/compiler/classExtendsNull.ts @@ -0,0 +1,12 @@ +class C extends null { + constructor() { + super(); + return Object.create(null); + } +} + +class D extends null { + constructor() { + return Object.create(null); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/commentsArgumentsOfCallExpression1.ts b/tests/cases/compiler/commentsArgumentsOfCallExpression1.ts new file mode 100644 index 00000000000..4dfab371d62 --- /dev/null +++ b/tests/cases/compiler/commentsArgumentsOfCallExpression1.ts @@ -0,0 +1,15 @@ +function foo(/*c1*/ x: any) { } +foo(/*c2*/ 1); +foo(/*c3*/ function () { }); +foo( + /*c4*/ + () => { }); +foo( + /*c5*/ + /*c6*/ + () => { }); +foo(/*c7*/ + () => { }); +foo( + /*c7*/ + /*c8*/() => { }); \ No newline at end of file diff --git a/tests/cases/compiler/commentsArgumentsOfCallExpression2.ts b/tests/cases/compiler/commentsArgumentsOfCallExpression2.ts new file mode 100644 index 00000000000..65350880b5d --- /dev/null +++ b/tests/cases/compiler/commentsArgumentsOfCallExpression2.ts @@ -0,0 +1,10 @@ +function foo(/*c1*/ x: any, /*d1*/ y: any,/*e1*/w?: any) { } +var a, b: any; +foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); +foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); +foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); +foo( + /*c4*/ function () { }, + /*d4*/() => { }, + /*e4*/ + /*e5*/ "hello"); \ No newline at end of file diff --git a/tests/cases/compiler/commentsOnPropertyOfObjectLiteral1.ts b/tests/cases/compiler/commentsOnPropertyOfObjectLiteral1.ts new file mode 100644 index 00000000000..6ecf7a754bd --- /dev/null +++ b/tests/cases/compiler/commentsOnPropertyOfObjectLiteral1.ts @@ -0,0 +1,13 @@ +var resolve = { + id: /*! @ngInject */ (details: any) => details.id, + id1: /* c1 */ "hello", + id2: + /*! @ngInject */ (details: any) => details.id, + id3: + /*! @ngInject */ + (details: any) => details.id, + id4: + /*! @ngInject */ + /* C2 */ + (details: any) => details.id, +}; \ No newline at end of file diff --git a/tests/cases/compiler/commonjsSafeImport.ts b/tests/cases/compiler/commonjsSafeImport.ts new file mode 100644 index 00000000000..ce494ee54ad --- /dev/null +++ b/tests/cases/compiler/commonjsSafeImport.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @module: commonjs +// @declaration: true +// @filename: 10_lib.ts + +export function Foo() {} + +// @filename: main.ts +import { Foo } from './10_lib'; + +Foo(); diff --git a/tests/cases/compiler/constEnumToStringNoComments.ts b/tests/cases/compiler/constEnumToStringNoComments.ts new file mode 100644 index 00000000000..802ee9068bb --- /dev/null +++ b/tests/cases/compiler/constEnumToStringNoComments.ts @@ -0,0 +1,22 @@ +// @comments: false +const enum Foo { + X = 100, + Y = 0.5, + Z = 2., + A = -1, + B = -1.5, + C = -1. +} + +let x0 = Foo.X.toString(); +let x1 = Foo["X"].toString(); +let y0 = Foo.Y.toString(); +let y1 = Foo["Y"].toString(); +let z0 = Foo.Z.toString(); +let z1 = Foo["Z"].toString(); +let a0 = Foo.A.toString(); +let a1 = Foo["A"].toString(); +let b0 = Foo.B.toString(); +let b1 = Foo["B"].toString(); +let c0 = Foo.C.toString(); +let c1 = Foo["C"].toString(); diff --git a/tests/cases/compiler/constEnumToStringWithComments.ts b/tests/cases/compiler/constEnumToStringWithComments.ts new file mode 100644 index 00000000000..e10c3591131 --- /dev/null +++ b/tests/cases/compiler/constEnumToStringWithComments.ts @@ -0,0 +1,22 @@ +// @comments: true +const enum Foo { + X = 100, + Y = 0.5, + Z = 2., + A = -1, + B = -1.5, + C = -1. +} + +let x0 = Foo.X.toString(); +let x1 = Foo["X"].toString(); +let y0 = Foo.Y.toString(); +let y1 = Foo["Y"].toString(); +let z0 = Foo.Z.toString(); +let z1 = Foo["Z"].toString(); +let a0 = Foo.A.toString(); +let a1 = Foo["A"].toString(); +let b0 = Foo.B.toString(); +let b1 = Foo["B"].toString(); +let c0 = Foo.C.toString(); +let c1 = Foo["C"].toString(); diff --git a/tests/cases/compiler/declFileClassExtendsNull.ts b/tests/cases/compiler/declFileClassExtendsNull.ts new file mode 100644 index 00000000000..d21fd5d3805 --- /dev/null +++ b/tests/cases/compiler/declFileClassExtendsNull.ts @@ -0,0 +1,5 @@ +// @target: ES5 +// @declaration: true + +class ExtendsNull extends null { +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_exportAssignment.ts b/tests/cases/compiler/declarationEmit_exportAssignment.ts new file mode 100644 index 00000000000..166f4abe8e7 --- /dev/null +++ b/tests/cases/compiler/declarationEmit_exportAssignment.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: utils.ts +export function foo() { } +export function bar() { } +export interface Buzz { } + +// @filename: index.ts +import {foo} from "utils"; +export = foo; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_exportDeclaration.ts b/tests/cases/compiler/declarationEmit_exportDeclaration.ts new file mode 100644 index 00000000000..a9e0bda761f --- /dev/null +++ b/tests/cases/compiler/declarationEmit_exportDeclaration.ts @@ -0,0 +1,15 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: utils.ts +export function foo() { } +export function bar() { } +export interface Buzz { } + +// @filename: index.ts +import {foo, bar, Buzz} from "utils"; + +foo(); +let obj: Buzz; +export {bar}; \ No newline at end of file diff --git a/tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts b/tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts new file mode 100644 index 00000000000..b47474fdd74 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts @@ -0,0 +1,17 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 + +declare var decorator: any; + +class MyClass { + constructor(test: string, test2: number) { + + } + + @decorator + doSomething() { + + } +} diff --git a/tests/cases/compiler/decoratorMetadataWithConstructorType.ts b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts new file mode 100644 index 00000000000..31c42ee9b43 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts @@ -0,0 +1,21 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts new file mode 100644 index 00000000000..8d198e44752 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts new file mode 100644 index 00000000000..ac097dd3ba4 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts new file mode 100644 index 00000000000..e15570cb5ba --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts new file mode 100644 index 00000000000..d04d1300531 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts new file mode 100644 index 00000000000..24934963b3e --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts new file mode 100644 index 00000000000..2043279c4aa --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts new file mode 100644 index 00000000000..bbedf61c6df --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts new file mode 100644 index 00000000000..e3318d813a8 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/es6ImportEqualsDeclaration2.ts b/tests/cases/compiler/es6ImportEqualsDeclaration2.ts new file mode 100644 index 00000000000..554740d80e1 --- /dev/null +++ b/tests/cases/compiler/es6ImportEqualsDeclaration2.ts @@ -0,0 +1,19 @@ +// @target: es6 + +// @filename: server.d.ts +declare module "other" { + export class C { } +} + +declare module "server" { + import events = require("other"); // Ambient declaration, no error expected. + + module S { + export var a: number; + } + + export = S; // Ambient declaration, no error expected. +} + +// @filename: client.ts +import {a} from "server"; diff --git a/tests/cases/compiler/excessPropertyErrorsSuppressed.ts b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts new file mode 100644 index 00000000000..21bfee420c1 --- /dev/null +++ b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts @@ -0,0 +1,3 @@ +//@suppressExcessPropertyErrors: true + +var x: { a: string } = { a: "hello", b: 42 }; // No error diff --git a/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts b/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts index d8ddcf4bb8f..814f1b41619 100644 --- a/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts +++ b/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts @@ -3,5 +3,5 @@ (...arg) => 103; (...arg:number [] = []) => 104; -// Non optional parameter following an optional one +// Uninitialized parameter makes the initialized one required (arg1 = 1, arg2) => 1; \ No newline at end of file diff --git a/tests/cases/compiler/forwardRefInEnum.ts b/tests/cases/compiler/forwardRefInEnum.ts new file mode 100644 index 00000000000..97bc1819d7b --- /dev/null +++ b/tests/cases/compiler/forwardRefInEnum.ts @@ -0,0 +1,13 @@ +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} diff --git a/tests/cases/compiler/inferringAnyFunctionType1.ts b/tests/cases/compiler/inferringAnyFunctionType1.ts new file mode 100644 index 00000000000..bc1e6f68973 --- /dev/null +++ b/tests/cases/compiler/inferringAnyFunctionType1.ts @@ -0,0 +1,5 @@ +function f number }>(p: T): T { + return p; +} + +var v = f([x => x]); \ No newline at end of file diff --git a/tests/cases/compiler/inferringAnyFunctionType2.ts b/tests/cases/compiler/inferringAnyFunctionType2.ts new file mode 100644 index 00000000000..0984e578f67 --- /dev/null +++ b/tests/cases/compiler/inferringAnyFunctionType2.ts @@ -0,0 +1,5 @@ +function f number]>(p: T): T { + return p; +} + +var v = f([x => x]); \ No newline at end of file diff --git a/tests/cases/compiler/inferringAnyFunctionType3.ts b/tests/cases/compiler/inferringAnyFunctionType3.ts new file mode 100644 index 00000000000..4576a30898a --- /dev/null +++ b/tests/cases/compiler/inferringAnyFunctionType3.ts @@ -0,0 +1,5 @@ +function f number)[]>(p: T): T { + return p; +} + +var v = f([x => x]); \ No newline at end of file diff --git a/tests/cases/compiler/inferringAnyFunctionType4.ts b/tests/cases/compiler/inferringAnyFunctionType4.ts new file mode 100644 index 00000000000..592908bdfec --- /dev/null +++ b/tests/cases/compiler/inferringAnyFunctionType4.ts @@ -0,0 +1,5 @@ +function f number>(p: T): T { + return p; +} + +var v = f(x => x); \ No newline at end of file diff --git a/tests/cases/compiler/inferringAnyFunctionType5.ts b/tests/cases/compiler/inferringAnyFunctionType5.ts new file mode 100644 index 00000000000..2ff4a325c5a --- /dev/null +++ b/tests/cases/compiler/inferringAnyFunctionType5.ts @@ -0,0 +1,5 @@ +function f number }>(p: T): T { + return p; +} + +var v = f({ q: x => x }); \ No newline at end of file diff --git a/tests/cases/compiler/instanceOfAssignability.ts b/tests/cases/compiler/instanceOfAssignability.ts new file mode 100644 index 00000000000..909de1ff2a7 --- /dev/null +++ b/tests/cases/compiler/instanceOfAssignability.ts @@ -0,0 +1,88 @@ +interface Base { + foo: string|number; + optional?: number; +} + +// Derived1 is assignable to, but not a subtype of, Base +class Derived1 implements Base { + foo: string; +} +// Derived2 is a subtype of Base that is not assignable to Derived1 +class Derived2 implements Base { + foo: number; + optional: number; +} + +class Animal { + move; +} +class Mammal extends Animal { milk; } +class Giraffe extends Mammal { neck; } + +function fn1(x: Array|Array|boolean) { + if(x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; + } +} + +function fn2(x: Base) { + if(x instanceof Derived1) { + // 1.5: y: Base + // Want: y: Derived1 + let y = x; + } +} + +function fn3(x: Base|Derived1) { + if(x instanceof Derived2) { + // 1.5: y: Derived2 + // Want: Derived2 + let y = x; + } +} + +function fn4(x: Base|Derived2) { + if(x instanceof Derived1) { + // 1.5: y: {} + // Want: Derived1 + let y = x; + } +} + +function fn5(x: Derived1) { + if(x instanceof Derived2) { + // 1.5: y: Derived1 + // Want: ??? + let y = x; + } +} + +function fn6(x: Animal|Mammal) { + if(x instanceof Giraffe) { + // 1.5: y: Derived1 + // Want: ??? + let y = x; + } +} + +function fn7(x: Array|Array) { + if(x instanceof Array) { + // 1.5: y: Array|Array + // Want: y: Array|Array + let y = x; + } +} + +interface Alpha { a } +interface Beta { b } +interface Gamma { c } +class ABC { a; b; c; } +function fn8(x: Alpha|Beta|Gamma) { + if(x instanceof ABC) { + let y = x; + } +} + + diff --git a/tests/cases/compiler/jsxHash.tsx b/tests/cases/compiler/jsxHash.tsx new file mode 100644 index 00000000000..ddd6c7e928f --- /dev/null +++ b/tests/cases/compiler/jsxHash.tsx @@ -0,0 +1,12 @@ +//@jsx: preserve +var t02 = {0}#; +var t03 = #{0}; +var t04 = #{0}#; +var t05 = #; +var t06 = #; +var t07 = ##; +var t08 = #; +var t09 = ##; +var t10 = #; +var t11 = #; +var t12 = #; diff --git a/tests/cases/compiler/jsxViaImport.tsx b/tests/cases/compiler/jsxViaImport.tsx new file mode 100644 index 00000000000..5b3b7e11d83 --- /dev/null +++ b/tests/cases/compiler/jsxViaImport.tsx @@ -0,0 +1,23 @@ +//@jsx: preserve +//@module: commonjs + +//@filename: component.d.ts +declare module JSX { + interface ElementAttributesProperty { props; } +} +declare module React { + class Component { } +} +declare module "BaseComponent" { + var base: React.Component; + export = base; +} + +//@filename: consumer.tsx +/// +import BaseComponent = require('BaseComponent'); +class TestComponent extends React.Component { + render() { + return ; + } +} diff --git a/tests/cases/compiler/missingPropertiesOfClassExpression.ts b/tests/cases/compiler/missingPropertiesOfClassExpression.ts new file mode 100644 index 00000000000..a1d91355365 --- /dev/null +++ b/tests/cases/compiler/missingPropertiesOfClassExpression.ts @@ -0,0 +1,5 @@ +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} diff --git a/tests/cases/compiler/moduleResolutionNoResolve.ts b/tests/cases/compiler/moduleResolutionNoResolve.ts new file mode 100644 index 00000000000..aea0208b5d6 --- /dev/null +++ b/tests/cases/compiler/moduleResolutionNoResolve.ts @@ -0,0 +1,8 @@ +// @module:commonjs +// @noResolve: true + +// @filename: a.ts +import a = require('./b'); + +// @filename: b.ts +export var c = ''; diff --git a/tests/cases/compiler/nodeResolution1.ts b/tests/cases/compiler/nodeResolution1.ts new file mode 100644 index 00000000000..19316ef251b --- /dev/null +++ b/tests/cases/compiler/nodeResolution1.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: a.ts +export var x = 1; + +// @filename: b.ts +import y = require("./a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution2.ts b/tests/cases/compiler/nodeResolution2.ts new file mode 100644 index 00000000000..9d1972c7239 --- /dev/null +++ b/tests/cases/compiler/nodeResolution2.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a.d.ts +export var x: number; + +// @filename: b.ts +import y = require("a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution3.ts b/tests/cases/compiler/nodeResolution3.ts new file mode 100644 index 00000000000..ede8f76dbbe --- /dev/null +++ b/tests/cases/compiler/nodeResolution3.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/b/index.d.ts +export var x: number; + +// @filename: a.ts +import y = require("b"); \ No newline at end of file diff --git a/tests/cases/compiler/optionalParamArgsTest.ts b/tests/cases/compiler/optionalParamArgsTest.ts index ce34acae869..609cbfe4734 100644 --- a/tests/cases/compiler/optionalParamArgsTest.ts +++ b/tests/cases/compiler/optionalParamArgsTest.ts @@ -30,8 +30,7 @@ class C1 { public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; } - // Negative test - // "Optional parameters may only be followed by other optional parameters" + // Uninitialized parameter makes the initialized one required public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; } } diff --git a/tests/cases/compiler/out-flag2.ts b/tests/cases/compiler/out-flag2.ts new file mode 100644 index 00000000000..d3349563a9f --- /dev/null +++ b/tests/cases/compiler/out-flag2.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/out-flag3.ts b/tests/cases/compiler/out-flag3.ts new file mode 100644 index 00000000000..cb3c6819811 --- /dev/null +++ b/tests/cases/compiler/out-flag3.ts @@ -0,0 +1,14 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js +// @out: d.js + +// --out and --outFile error + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/paramterDestrcuturingDeclaration.ts b/tests/cases/compiler/paramterDestrcuturingDeclaration.ts new file mode 100644 index 00000000000..d05d6076bf0 --- /dev/null +++ b/tests/cases/compiler/paramterDestrcuturingDeclaration.ts @@ -0,0 +1,6 @@ +// @declaration: true + +interface C { + ({p: name}): any; + new ({p: boolean}): any; +} diff --git a/tests/cases/compiler/recursiveTupleTypes1.ts b/tests/cases/compiler/recursiveTupleTypes1.ts new file mode 100644 index 00000000000..82559eccfad --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes1.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/recursiveTupleTypes2.ts b/tests/cases/compiler/recursiveTupleTypes2.ts new file mode 100644 index 00000000000..78c8efa82a4 --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes2.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/requiredInitializedParameter1.ts b/tests/cases/compiler/requiredInitializedParameter1.ts new file mode 100644 index 00000000000..35d606426f0 --- /dev/null +++ b/tests/cases/compiler/requiredInitializedParameter1.ts @@ -0,0 +1,19 @@ +function f1(a, b = 0, c) { } +function f2(a, b = 0, c = 0) { } +function f3(a, b = 0, c?) { } +function f4(a, b = 0, ...c) { } + +f1(0, 1, 2); +f2(0, 1, 2); +f3(0, 1, 2); +f4(0, 1, 2); + +f1(0, 1); +f2(0, 1); +f3(0, 1); +f4(0, 1); + +f1(0); +f2(0); +f3(0); +f4(0); \ No newline at end of file diff --git a/tests/cases/compiler/requiredInitializedParameter2.ts b/tests/cases/compiler/requiredInitializedParameter2.ts new file mode 100644 index 00000000000..48d42869ee7 --- /dev/null +++ b/tests/cases/compiler/requiredInitializedParameter2.ts @@ -0,0 +1,7 @@ +interface I1 { + method(); +} + +class C1 implements I1 { + method(a = 0, b) { } +} \ No newline at end of file diff --git a/tests/cases/compiler/requiredInitializedParameter3.ts b/tests/cases/compiler/requiredInitializedParameter3.ts new file mode 100644 index 00000000000..803eefb6342 --- /dev/null +++ b/tests/cases/compiler/requiredInitializedParameter3.ts @@ -0,0 +1,8 @@ +//@declaration: true +interface I1 { + method(); +} + +class C1 implements I1 { + method(a = 0, b?) { } +} \ No newline at end of file diff --git a/tests/cases/compiler/requiredInitializedParameter4.ts b/tests/cases/compiler/requiredInitializedParameter4.ts new file mode 100644 index 00000000000..4ba15878e43 --- /dev/null +++ b/tests/cases/compiler/requiredInitializedParameter4.ts @@ -0,0 +1,4 @@ +//@declaration: true +class C1 { + method(a = 0, b) { } +} \ No newline at end of file diff --git a/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts b/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts new file mode 100644 index 00000000000..a0f1094e3f7 --- /dev/null +++ b/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts @@ -0,0 +1,2 @@ +interface bar { } +let bar: bar; diff --git a/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts b/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts new file mode 100644 index 00000000000..5f40f5fd4bc --- /dev/null +++ b/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts @@ -0,0 +1,4 @@ +interface foo { } +interface bar { } +let bar: bar | foo; +let foo: bar | foo; \ No newline at end of file diff --git a/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts b/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts new file mode 100644 index 00000000000..d76a3b0ba0d --- /dev/null +++ b/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts @@ -0,0 +1,8 @@ +declare module foo { + + interface Bar { + + } +} + +let foo: foo.Bar; \ No newline at end of file diff --git a/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts b/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts new file mode 100644 index 00000000000..34bad893a75 --- /dev/null +++ b/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts @@ -0,0 +1,8 @@ +declare module "punycode" { + interface ucs2 { + decode(string: string): string; + encode(codePoints: number[]): string; + } + + export let ucs2: ucs2; +} \ No newline at end of file diff --git a/tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts b/tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts new file mode 100644 index 00000000000..2f3b42972dc --- /dev/null +++ b/tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts @@ -0,0 +1,3 @@ +class C { } +type baz = C; +let baz: baz; diff --git a/tests/cases/compiler/shebang.ts b/tests/cases/compiler/shebang.ts new file mode 100644 index 00000000000..3456df0fad5 --- /dev/null +++ b/tests/cases/compiler/shebang.ts @@ -0,0 +1,2 @@ +#!/usr/bin/env node +var foo = 'I wish the generated JS to be executed in node'; diff --git a/tests/cases/compiler/shebangError.ts b/tests/cases/compiler/shebangError.ts new file mode 100644 index 00000000000..91a27a65aa0 --- /dev/null +++ b/tests/cases/compiler/shebangError.ts @@ -0,0 +1,2 @@ +var foo = 'Shebang is only allowed on the first line'; +#!/usr/bin/env node \ No newline at end of file diff --git a/tests/cases/compiler/sourceMap-Comments.ts b/tests/cases/compiler/sourceMap-Comments.ts new file mode 100644 index 00000000000..6b810858d6e --- /dev/null +++ b/tests/cases/compiler/sourceMap-Comments.ts @@ -0,0 +1,21 @@ +// @target: ES5 +// @sourcemap: true +module sas.tools { + export class Test { + public doX(): void { + let f: number = 2; + switch (f) { + case 1: + break; + case 2: + //line comment 1 + //line comment 2 + break; + case 3: + //a comment + break; + } + } + } + +} diff --git a/tests/cases/compiler/sourceMap-Comments2.ts b/tests/cases/compiler/sourceMap-Comments2.ts new file mode 100644 index 00000000000..7a064c81c9f --- /dev/null +++ b/tests/cases/compiler/sourceMap-Comments2.ts @@ -0,0 +1,21 @@ +// @target: ES5 +// @sourcemap: true +function foo(str: string, num: number): void { + return; +} + +/** + * some sort of block quote + */ +function bar(str: string, num: number): void { + return; +} + +// some sort of comment +function baz(str: string, num: number): void { + return; +} + +function qat(str: string, num: number): void { + return; +} \ No newline at end of file diff --git a/tests/cases/compiler/superCallInsideClassDeclaration.ts b/tests/cases/compiler/superCallInsideClassDeclaration.ts new file mode 100644 index 00000000000..c0d18fe3661 --- /dev/null +++ b/tests/cases/compiler/superCallInsideClassDeclaration.ts @@ -0,0 +1,16 @@ +class A { +} + +class C { +} + +class B extends A { + constructor() { + + class D extends C { + constructor() { + super(); + } + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/superCallInsideClassExpression.ts b/tests/cases/compiler/superCallInsideClassExpression.ts new file mode 100644 index 00000000000..71a714dd094 --- /dev/null +++ b/tests/cases/compiler/superCallInsideClassExpression.ts @@ -0,0 +1,16 @@ +class A { +} + +class C { +} + +class B extends A { + constructor() { + + var D = class extends C { + constructor() { + super(); + } + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/superCallInsideObjectLiteralExpression.ts b/tests/cases/compiler/superCallInsideObjectLiteralExpression.ts new file mode 100644 index 00000000000..c673a5b8a03 --- /dev/null +++ b/tests/cases/compiler/superCallInsideObjectLiteralExpression.ts @@ -0,0 +1,12 @@ +class A { + foo() { + } +} + +class B extends A { + constructor() { + var x = { + x: super() + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/superCallWithMissingBaseClass.ts b/tests/cases/compiler/superCallWithMissingBaseClass.ts new file mode 100644 index 00000000000..6f7ede10191 --- /dev/null +++ b/tests/cases/compiler/superCallWithMissingBaseClass.ts @@ -0,0 +1,9 @@ +class Foo extends Bar { + m1() { + return super.m1(); + } + + static m2() { + return super.m2(); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/systemModule14.ts b/tests/cases/compiler/systemModule14.ts new file mode 100644 index 00000000000..91192cec74a --- /dev/null +++ b/tests/cases/compiler/systemModule14.ts @@ -0,0 +1,12 @@ +// @module: system +// @isolatedModules: true + +function foo() { + return a; +} + +import {a} from "foo"; +export {foo} + +var x = 1; +export {foo as b} \ No newline at end of file diff --git a/tests/cases/compiler/systemModule15.ts b/tests/cases/compiler/systemModule15.ts new file mode 100644 index 00000000000..2c29f0a5d20 --- /dev/null +++ b/tests/cases/compiler/systemModule15.ts @@ -0,0 +1,34 @@ +// @module: system +// @isolatedModules: true + +// @filename: file1.ts + +import * as moduleB from "./file2" + +declare function use(v: any): void; + +use(moduleB.value); +use(moduleB.moduleC); +use(moduleB.moduleCStar); + +// @filename: file2.ts + +import * as moduleCStar from "./file3" +import {value2} from "./file4" +import moduleC from "./file3" +import {value} from "./file3" + +export { + moduleCStar, + moduleC, + value +} + +// @filename: file3.ts + +export var value = "youpi"; +export default value; + +// @filename: file4.ts + +export var value2 = "v"; \ No newline at end of file diff --git a/tests/cases/compiler/systemModule16.ts b/tests/cases/compiler/systemModule16.ts new file mode 100644 index 00000000000..ba64bd32b59 --- /dev/null +++ b/tests/cases/compiler/systemModule16.ts @@ -0,0 +1,13 @@ +// @module: system +// @isolatedModules: true + +import * as x from "foo"; +import * as y from "bar"; +export * from "foo"; +export * from "bar" +export {x} +export {y} +import {a1, b1, c1 as d1} from "foo"; +export {a2, b2, c2 as d2} from "bar"; + +x,y,a1,b1,d1; diff --git a/tests/cases/compiler/systemModuleWithSuperClass.ts b/tests/cases/compiler/systemModuleWithSuperClass.ts new file mode 100644 index 00000000000..2f1c21f4d48 --- /dev/null +++ b/tests/cases/compiler/systemModuleWithSuperClass.ts @@ -0,0 +1,12 @@ +// @module: system + +// @Filename: foo.ts +export class Foo { + a: string; +} + +// @Filename: bar.ts +import {Foo} from './foo'; +export class Bar extends Foo { + b: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/tupleTypeInference.ts b/tests/cases/compiler/tupleTypeInference.ts new file mode 100644 index 00000000000..7c5a49d3ca1 --- /dev/null +++ b/tests/cases/compiler/tupleTypeInference.ts @@ -0,0 +1,21 @@ +declare var $q: IQService; + +interface IQService { + all(x: [IPromise, IPromise, IPromise]): IPromise<[T1, T2, T3]>; + all(x: [IPromise, IPromise]): IPromise<[T1, T2]>; + all(x: [IPromise]): IPromise<[T1]>; + when(t?: T): IPromise; +} + +interface IPromise { + then(callback: (t: T) => TResult): IPromise; +} + +// Implicit different types +var a = $q.all([$q.when(), $q.when()]); + +// Explicit different types +var b = $q.all([$q.when(), $q.when()]); + +// Implicit identical types +var c = $q.all([$q.when(), $q.when()]); diff --git a/tests/cases/compiler/typeAliasDeclarationEmit.ts b/tests/cases/compiler/typeAliasDeclarationEmit.ts new file mode 100644 index 00000000000..be7e40453f6 --- /dev/null +++ b/tests/cases/compiler/typeAliasDeclarationEmit.ts @@ -0,0 +1,7 @@ +// @target: ES5 +// @module: AMD +// @declaration: true + +export type callback = () => T; + +export type CallbackArray = () => T; \ No newline at end of file diff --git a/tests/cases/compiler/typeAliasDeclarationEmit2.ts b/tests/cases/compiler/typeAliasDeclarationEmit2.ts new file mode 100644 index 00000000000..33aecd7d5c9 --- /dev/null +++ b/tests/cases/compiler/typeAliasDeclarationEmit2.ts @@ -0,0 +1,5 @@ +// @target: ES5 +// @module: AMD +// @declaration: true + +export type A = { value: a }; \ No newline at end of file diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts new file mode 100644 index 00000000000..cffb7654834 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts @@ -0,0 +1,7 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts new file mode 100644 index 00000000000..4ca5c9fc663 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts @@ -0,0 +1,12 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts new file mode 100644 index 00000000000..4a6f6cc3d61 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts @@ -0,0 +1,8 @@ +abstract class A { } + +// var AA: typeof A; +var AAA: new() => A; + +// AA = A; // okay +AAA = A; // error. +AAA = "asdf"; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classExpressions/extendClassExpressionFromModule.ts b/tests/cases/conformance/classes/classExpressions/extendClassExpressionFromModule.ts new file mode 100644 index 00000000000..d4d25743333 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/extendClassExpressionFromModule.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @Filename: foo1.ts +class x{} + +export = x; + +// @Filename: foo2.ts +import foo1 = require('./foo1'); +var x = foo1; +class y extends x {} diff --git a/tests/cases/conformance/decorators/decoratorMetadata.ts b/tests/cases/conformance/decorators/decoratorMetadata.ts new file mode 100644 index 00000000000..3f622909309 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadata.ts @@ -0,0 +1,17 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +// @module: commonjs +// @filename: service.ts +export default class Service { +} +// @filename: component.ts +import Service from "./service"; + +declare var decorator: any; + +@decorator +class MyComponent { + constructor(public Service: Service) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts new file mode 100644 index 00000000000..7caa9caf574 --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts @@ -0,0 +1,31 @@ +// @module: commonjs +// @target: ES5 + +// @filename: m1.ts +export default function Decl() { + return 0; +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + export var x = 10; + export var y = 20; + + interface I { + } +} + +// @filename: m2.ts +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; + +Entity.x; +Entity.y; \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts new file mode 100644 index 00000000000..f7312ec2e66 --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts @@ -0,0 +1,26 @@ +// @module: commonjs +// @target: ES5 + +// @filename: m1.ts +export default class Decl { +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + interface I { + } +} + +// @filename: m2.ts +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts new file mode 100644 index 00000000000..dad8431812b --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts @@ -0,0 +1,26 @@ +// @module: commonjs +// @target: ES5 + +// @filename: m1.ts +export default class Decl { +} + +interface Decl { + p1: number; + p2: number; +} + +namespace Decl { + interface I { + } +} + +// @filename: m2.ts +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts new file mode 100644 index 00000000000..ab72d10504a --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts @@ -0,0 +1,15 @@ +// @module: commonjs +// @target: ES5 + +export default function Foo() { +} + +namespace Foo { + export var x; +} + +interface Foo { +} + +export interface Foo { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts new file mode 100644 index 00000000000..84172248e93 --- /dev/null +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts @@ -0,0 +1,19 @@ +// @module: commonjs +// @target: ES5 + +// @filename: m1.ts +export default class foo { + +} + +export default function bar() { + +} + +var x = 10; +export default x; + +// @filename: m2.ts +import Entity from "m1" + +Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts new file mode 100644 index 00000000000..1e9c8dabc13 --- /dev/null +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts @@ -0,0 +1,16 @@ +// @module: commonjs +// @target: ES5 + +// @filename: m1.ts +export default function foo() { + +} + +export default function bar() { + +} + +// @filename: m2.ts +import Entity from "m1" + +Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts index 1b1e3cfab6c..f72845c18a4 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts @@ -1,8 +1,8 @@ -// In the true branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { diff --git a/tests/cases/conformance/externalModules/reexportClassDefinition.ts b/tests/cases/conformance/externalModules/reexportClassDefinition.ts new file mode 100644 index 00000000000..31d90fd7fd2 --- /dev/null +++ b/tests/cases/conformance/externalModules/reexportClassDefinition.ts @@ -0,0 +1,16 @@ +// @module: commonjs +// @Filename: foo1.ts +class x{} +export = x; + +// @Filename: foo2.ts +import foo1 = require('./foo1'); + +export = { + x: foo1 +} + +// @Filename: foo3.ts +import foo2 = require('./foo2') +class x extends foo2.x {} + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution10.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution10.tsx new file mode 100644 index 00000000000..759cc28d322 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution10.tsx @@ -0,0 +1,31 @@ +//@jsx: preserve +//@module: amd + +//@filename: react.d.ts +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } +} + +//@filename: file.tsx +export class MyComponent { + render() { + } + + props: { + [s: string]: boolean; + } +} + +// Should be an error +; + +// Should be OK +; + +// Should be ok +; diff --git a/tests/cases/conformance/jsx/tsxEmit3.tsx b/tests/cases/conformance/jsx/tsxEmit3.tsx index b3c3350dd11..bb3ce903682 100644 --- a/tests/cases/conformance/jsx/tsxEmit3.tsx +++ b/tests/cases/conformance/jsx/tsxEmit3.tsx @@ -1,5 +1,7 @@ //@filename: file.tsx //@jsx: preserve +//@sourceMap: true + declare module JSX { interface Element { } interface IntrinsicElements { } diff --git a/tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx b/tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx new file mode 100644 index 00000000000..fa14d14d699 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx @@ -0,0 +1,17 @@ +//@jsx: react +//@module: commonjs + +//@filename: modules.d.ts +declare module 'mod' { + var y: any; + export default y; +} + +//@filename: app.tsx +import Main from 'mod'; +declare var Foo, React; +// Should see mod_1['default'] in emit here +; +// Should see mod_1['default'] in emit here +; + diff --git a/tests/cases/conformance/jsx/tsxReactEmit5.tsx b/tests/cases/conformance/jsx/tsxReactEmit5.tsx new file mode 100644 index 00000000000..c961a23ecfc --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit5.tsx @@ -0,0 +1,20 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: test.d.ts +export var React; + +//@filename: react-consumer.tsx +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit6.tsx b/tests/cases/conformance/jsx/tsxReactEmit6.tsx new file mode 100644 index 00000000000..2782f90e503 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit6.tsx @@ -0,0 +1,22 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: react-consumer.tsx +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} diff --git a/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx new file mode 100644 index 00000000000..4b7dc5780f8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx new file mode 100644 index 00000000000..964064979ec --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + diff --git a/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts new file mode 100644 index 00000000000..5e5c2e85485 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parseRegularExpressionMixedWithComments.ts @@ -0,0 +1,6 @@ +var regex1 = / asdf /; +var regex2 = /**// asdf /; +var regex3 = /**///**/ asdf / // should be a comment line +1; +var regex4 = /**// /**/asdf /; +var regex5 = /**// asdf/**/ /; \ No newline at end of file diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts index 1261de3299e..ca599329743 100644 --- a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts @@ -25,12 +25,12 @@ unionOfDifferentNumberOfSignatures(); // error - no call signatures unionOfDifferentNumberOfSignatures(10); // error - no call signatures unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures - var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; +var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; unionWithDifferentParameterCount();// no call signature unionWithDifferentParameterCount("hello");// no call signature unionWithDifferentParameterCount("hello", 10);// no call signature - var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; +var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); strOrNum = unionWithOptionalParameter1('hello', 10); strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type @@ -43,7 +43,7 @@ strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signa strOrNum = unionWithOptionalParameter2(); // error no call signature var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; }; -strOrNum = unionWithOptionalParameter3('hello'); // error no call signature +strOrNum = unionWithOptionalParameter3('hello'); strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature strOrNum = unionWithOptionalParameter3(); // error no call signature @@ -63,8 +63,9 @@ strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature strOrNum = unionWithRestParameter2(); // error no call signature var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number }; -strOrNum = unionWithRestParameter3('hello'); // error no call signature +strOrNum = unionWithRestParameter3('hello'); strOrNum = unionWithRestParameter3('hello', 10); // error no call signature strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature -strOrNum = unionWithRestParameter3(); // error no call signature \ No newline at end of file +strOrNum = unionWithRestParameter3(); // error no call signature + diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures2.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures2.ts new file mode 100644 index 00000000000..2fa5190cc35 --- /dev/null +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures2.ts @@ -0,0 +1,35 @@ +interface A { + (x: number): number; + (x: string, y?: string): boolean; + (x: Date): void; + (x: T[]): T[]; +} + +interface B { + (x: number): number; + (x: string): string; + (x: Date): void; + (x: T[]): T[]; +} + +interface C { + (x: string, ...y: string[]): number; + (x: number, s?: string): number; + (x: T[]): T[]; +} + +var f1: A | B | C; +var n1 = f1(42); // number +var s1 = f1("abc"); // boolean | string | number +var a1 = f1([true, false]); // boolean[] + +var f2: C | B | A; +var n2 = f2(42); // number +var s2 = f2("abc"); // number | string | boolean +var a2 = f2([true, false]); // boolean[] + +var f3: B | A | C; +var n3 = f3(42); // number +var s3 = f3("abc"); // string | boolean | number +var a3 = f3([true, false]); // boolean[] + diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures3.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures3.ts new file mode 100644 index 00000000000..8549315a319 --- /dev/null +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures3.ts @@ -0,0 +1,11 @@ +function f1(s: string) { } +function f2(s?: string) { } +function f3(...s: string[]) { } +function f4(s: string, s2?: string) { } +function f5(s?: string, n?: number) { } +function f6(s?: string, ...n: number[]) { } +function f7(s: string, ...sRest: string[]) { } + +var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7; + +fUnion(""); // All constituents can be called by passing a single string. diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index d7ccbe73f33..5a8f661789c 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -24,7 +24,7 @@ goTo.marker('1'); verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]'); goTo.marker('2'); -verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]'); +verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); verify.quickInfoIs('var c2: ({\n\ diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts index 0b2d50fc130..c2d7bc406a5 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty2.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -1,12 +1,12 @@ /// ////interface One { -//// commonProperty: number; +//// commonProperty: string; //// commonFunction(): number; ////} //// ////interface Two { -//// commonProperty: string +//// commonProperty: number; //// commonFunction(): number; ////} //// @@ -15,6 +15,6 @@ ////x.commonProperty./**/ goTo.marker(); -verify.memberListContains("toString", "(property) toString: ((radix?: number) => string) | (() => string)"); -verify.memberListContains("valueOf", "(method) valueOf(): number | string"); +verify.memberListContains("toString", "(method) toString(): string"); +verify.memberListContains("valueOf", "(method) valueOf(): string | number"); verify.memberListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts new file mode 100644 index 00000000000..5424c8e79fa --- /dev/null +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -0,0 +1,62 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @/*1*/ */ +////var v1; +//// +/////** @p/*2*/ */ +////var v2; +//// +/////** @param /*3*/ */ +////var v3; +//// +/////** @param { n/*4*/ } bar */ +////var v4; +//// +/////** @type { n/*5*/ } */ +////var v5; +//// +////// @/*6*/ +////var v6; +//// +////// @pa/*7*/ +////var v7; +//// +/////** @param { n/*8*/ } */ +////var v8; +//// +/////** @return { n/*9*/ } */ +////var v9; + +goTo.marker('1'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('2'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('3'); +verify.completionListIsEmpty(); + +goTo.marker('4'); +verify.completionListContains('number'); + +goTo.marker('5'); +verify.completionListContains('number'); + +goTo.marker('6'); +verify.completionListIsEmpty(); + +goTo.marker('7'); +verify.completionListIsEmpty(); + +goTo.marker('8'); +verify.completionListContains('number'); + +goTo.marker('9'); +verify.completionListContains('number'); + diff --git a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts new file mode 100644 index 00000000000..903253b1a09 --- /dev/null +++ b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts @@ -0,0 +1,22 @@ +/// + +////function testArguments() {/*1*/} +/////*2*/ +////function testNestedArguments() { +//// function nestedfunction(){/*3*/} +////} +////function f() { +//// let g = () => /*4*/ +////} +////let g = () => /*5*/ + +goTo.marker('1'); +verify.completionListContains("arguments"); +goTo.marker('2'); +verify.not.completionListContains("arguments"); +goTo.marker('3'); +verify.completionListContains("arguments"); +goTo.marker('4'); +verify.completionListContains("arguments"); +goTo.marker('5'); +verify.not.completionListContains("arguments"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts new file mode 100644 index 00000000000..f8afcdc418c --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts @@ -0,0 +1,18 @@ +/// + +////var C0 = class D {} +////var C3 = class D{} +////var C5 = class D{} + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListIsEmpty(); +goTo.marker("3"); +verify.completionListIsEmpty(); +goTo.marker("4"); +verify.not.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts new file mode 100644 index 00000000000..e6017eedbfc --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts @@ -0,0 +1,17 @@ +/// + +////type List1 = T[]; +////type List4 = /*2*/T[]; +////type List3 = /*3*/; + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.not.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListContains("T"); +goTo.marker("3"); +verify.not.completionListIsEmpty(); +verify.not.completionListContains("T"); +verify.completionListContains("T1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts new file mode 100644 index 00000000000..80a910da798 --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts @@ -0,0 +1,19 @@ +/// + +////type Map1 = []; +////type Map1 = /*2*/[]; +////type Map1 = + +// @Filename: emptyFile.ts +/////*0*/ + +goTo.marker("0"); +verify.noDocCommentTemplate(); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts new file mode 100644 index 00000000000..f4410d5d454 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: functionWithParams.ts +/////*0*/ +//// /*1*/ +//// function foo(x: number, y: string): boolean {} + +const noIndentScaffolding = "/**\r\n * \r\n * @param x\r\n * @param y\r\n */"; +const oneIndentScaffolding = "/**\r\n * \r\n * @param x\r\n * @param y\r\n */"; +const noIndentOffset = 8; +const oneIndentOffset = noIndentOffset + 4; + +goTo.marker("0"); +verify.DocCommentTemplate(noIndentScaffolding, noIndentOffset); + +goTo.marker("1"); +verify.DocCommentTemplate(oneIndentScaffolding, oneIndentOffset); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts new file mode 100644 index 00000000000..131f722a9af --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts @@ -0,0 +1,7 @@ +/// + +// @Filename: justAComment.ts +//// /* /*0*/ */ + +goTo.marker("0"); +verify.noDocCommentTemplate(); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts new file mode 100644 index 00000000000..52925870a66 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: justAComment.ts +//// // We want to check off-by-one errors in assessing the end of the comment, so we check twice, +//// // first with a trailing space and then without. +//// // /*0*/ +//// // /*1*/ +//// // We also want to check EOF handling at the end of a comment +//// // /*2*/ + +test.markers().forEach((marker) => { + goTo.position(marker.position); + verify.noDocCommentTemplate(); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateIndentation.ts b/tests/cases/fourslash/docCommentTemplateIndentation.ts new file mode 100644 index 00000000000..db7e48dab2e --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateIndentation.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: indents.ts +/////*0*/ +//// /*1*/ +//// /*2*/function foo() { } + +const noIndentEmptyScaffolding = "/**\r\n * \r\n */"; +const oneIndentEmptyScaffolding = "/**\r\n * \r\n */"; +const twoIndentEmptyScaffolding = "/**\r\n * \r\n */\r\n "; +const noIndentOffset = 8; +const oneIndentOffset = noIndentOffset + 4; +const twoIndentOffset = oneIndentOffset + 4; + +goTo.marker("0"); +verify.DocCommentTemplate(noIndentEmptyScaffolding, noIndentOffset); + +goTo.marker("1"); +verify.DocCommentTemplate(oneIndentEmptyScaffolding, oneIndentOffset); + +goTo.marker("2"); +verify.DocCommentTemplate(twoIndentEmptyScaffolding, twoIndentOffset); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts new file mode 100644 index 00000000000..9c803301526 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts @@ -0,0 +1,9 @@ +/// + +// @Filename: functionDecl.ts +////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/} + +test.markers().forEach((marker) => { + goTo.position(marker.position); + verify.noDocCommentTemplate(); +}); diff --git a/tests/cases/fourslash/docCommentTemplateRegex.ts b/tests/cases/fourslash/docCommentTemplateRegex.ts new file mode 100644 index 00000000000..0bf50f5e85a --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateRegex.ts @@ -0,0 +1,9 @@ +/// + +// @Filename: regex.ts +////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; + +test.markers().forEach((marker) => { + goTo.position(marker.position); + verify.noDocCommentTemplate(); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/formatAsyncAwait.ts b/tests/cases/fourslash/formatAsyncAwait.ts new file mode 100644 index 00000000000..0530f868f91 --- /dev/null +++ b/tests/cases/fourslash/formatAsyncAwait.ts @@ -0,0 +1,19 @@ +/// + +////async function asyncFunction() {/*asyncKeyword*/ +//// await +/////*awaitExpressionIndent*/ +//// Promise.resolve("await");/*awaitExpressionAutoformat*/ +//// return await Promise.resolve("completed");/*awaitKeyword*/ +////} + +format.document(); + +goTo.marker("asyncKeyword"); +verify.currentLineContentIs("async function asyncFunction() {"); +goTo.marker("awaitExpressionIndent"); +verify.indentationIs(8); +goTo.marker("awaitExpressionAutoformat"); +verify.currentLineContentIs(' Promise.resolve("await");'); +goTo.marker("awaitKeyword"); +verify.currentLineContentIs(' return await Promise.resolve("completed");'); \ No newline at end of file diff --git a/tests/cases/fourslash/formatFunctionAndConstructorType.ts b/tests/cases/fourslash/formatFunctionAndConstructorType.ts new file mode 100644 index 00000000000..1b9655143f9 --- /dev/null +++ b/tests/cases/fourslash/formatFunctionAndConstructorType.ts @@ -0,0 +1,32 @@ +/// + +////function renderElement( +//// element: Element, +//// renderNode: +////(/*funcAutoformat*/ +//// node: Node/*funcParamAutoformat*/ +/////*funcIndent*/ +//// ) => void, +////newNode: +////new(/*constrAutoformat*/ +//// name: string/*constrParamAutoformat*/ +/////*constrIndent*/ +////) => Node +////): void { +////} + +format.document(); + +goTo.marker("funcAutoformat"); +verify.currentLineContentIs(" ("); +goTo.marker("funcParamAutoformat"); +verify.currentLineContentIs(" node: Node"); +goTo.marker("funcIndent"); +verify.indentationIs(12); + +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" new ("); +goTo.marker("constrParamAutoformat"); +verify.currentLineContentIs(" name: string"); +goTo.marker("constrIndent"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/formatParameter.ts b/tests/cases/fourslash/formatParameter.ts new file mode 100644 index 00000000000..827de0edf58 --- /dev/null +++ b/tests/cases/fourslash/formatParameter.ts @@ -0,0 +1,23 @@ +/// + +////function foo( +//// first: +//// number,/*first*/ +//// second: ( +//// string/*second*/ +//// ), +//// third: +//// ( +//// boolean/*third*/ +//// ) +////) { +////} + +format.document(); + +goTo.marker("first"); +verify.currentLineContentIs(" number,"); +goTo.marker("second"); +verify.currentLineContentIs(" string"); +goTo.marker("third"); +verify.currentLineContentIs(" boolean"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatSignatures.ts b/tests/cases/fourslash/formatSignatures.ts new file mode 100644 index 00000000000..f850ab48ef9 --- /dev/null +++ b/tests/cases/fourslash/formatSignatures.ts @@ -0,0 +1,31 @@ +/// + +////type Foo = { +//// ( +//// call: any/*callAutoformat*/ +/////*callIndent*/ +//// ): void; +//// new ( +//// constr: any/*constrAutoformat*/ +/////*constrIndent*/ +//// ): void; +//// method( +//// whatever: any/*methodAutoformat*/ +/////*methodIndent*/ +//// ): void; +////}; + +format.document(); + +goTo.marker("callAutoformat"); +verify.currentLineContentIs(" call: any"); +goTo.marker("callIndent"); +verify.indentationIs(8); +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" constr: any"); +goTo.marker("constrIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" whatever: any"); +goTo.marker("methodIndent"); +verify.indentationIs(8); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts index a1f5ef963da..6d1352fcf0d 100644 --- a/tests/cases/fourslash/formatTemplateLiteral.ts +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -2,6 +2,12 @@ ////var x = `sadasdasdasdasfegsfd /////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; ////var y = `1${2}/*2*/3`; +////let z= `foo`/*3*/ +////let w= `bar${3}`/*4*/ +////String.raw +//// `template`/*5*/ +////String.raw`foo`/*6*/ +////String.raw `bar${3}`/*7*/ goTo.marker("1"); @@ -10,4 +16,21 @@ edit.insert("\r\n"); // edit will trigger formatting - should succeeed goTo.marker("2"); edit.insert("\r\n"); verify.indentationIs(0); -verify.currentLineContentIs("3`;") \ No newline at end of file +verify.currentLineContentIs("3`;") + +goTo.marker("3"); +edit.insert(";"); +verify.currentLineContentIs("let z = `foo`;"); +goTo.marker("4"); +edit.insert(";"); +verify.currentLineContentIs("let w = `bar${3}`;"); + +goTo.marker("5"); +edit.insert(";"); +verify.currentLineContentIs(" `template`;"); +goTo.marker("6"); +edit.insert(";"); +verify.currentLineContentIs("String.raw `foo`;"); +goTo.marker("7"); +edit.insert(";"); +verify.currentLineContentIs("String.raw `bar${3}`;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTypeAlias.ts b/tests/cases/fourslash/formatTypeAlias.ts new file mode 100644 index 00000000000..c97a868c1f1 --- /dev/null +++ b/tests/cases/fourslash/formatTypeAlias.ts @@ -0,0 +1,14 @@ +/// + +////type Alias = /*typeKeyword*/ +/////*indent*/ +////number;/*autoformat*/ + +format.document(); + +goTo.marker("typeKeyword"); +verify.currentLineContentIs("type Alias ="); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" number;"); diff --git a/tests/cases/fourslash/formatTypeUnion.ts b/tests/cases/fourslash/formatTypeUnion.ts new file mode 100644 index 00000000000..267ba656612 --- /dev/null +++ b/tests/cases/fourslash/formatTypeUnion.ts @@ -0,0 +1,14 @@ +/// + +////type Union = number | {}/*formatOperator*/ +/////*indent*/ +////|string/*autoformat*/ + +format.document(); + +goTo.marker("formatOperator"); +verify.currentLineContentIs("type Union = number | {}"); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" | string"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts new file mode 100644 index 00000000000..d0c77804ed5 --- /dev/null +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -0,0 +1,19 @@ +/// + +//@Filename: file.tsx +////function () { +//// return ( +////
+////Hello, World!/*autoformat*/ +/////*indent*/ +////
+//// ) +////} +//// + + +format.document(); +goTo.marker("autoformat"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnChainedCallbacksAndPropertyAccesses.ts b/tests/cases/fourslash/formattingOnChainedCallbacksAndPropertyAccesses.ts new file mode 100644 index 00000000000..694f25f82e4 --- /dev/null +++ b/tests/cases/fourslash/formattingOnChainedCallbacksAndPropertyAccesses.ts @@ -0,0 +1,37 @@ +/// + +////var x = 1; + +////x +/////*1*/.toFixed + +////x +/////*2*/.toFixed() + +////x +/////*3*/.toFixed() +/////*4*/.length +/////*5*/.toString(); + +////x +/////*6*/.toFixed +/////*7*/.toString() +/////*8*/.length; + +format.document(); +goTo.marker('1'); +verify.currentLineContentIs(' .toFixed'); +goTo.marker('2'); +verify.currentLineContentIs(' .toFixed()'); +goTo.marker('3'); +verify.currentLineContentIs(' .toFixed()'); +goTo.marker('4'); +verify.currentLineContentIs(' .length'); +goTo.marker('5'); +verify.currentLineContentIs(' .toString();'); +goTo.marker('6'); +verify.currentLineContentIs(' .toFixed'); +goTo.marker('7'); +verify.currentLineContentIs(' .toString()'); +goTo.marker('8'); +verify.currentLineContentIs(' .length;'); diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index d84e876f06b..cdd8f61a215 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -6,6 +6,7 @@ /////*InsertSpaceAfterKeywordsInControlFlowStatements*/if (true) { } /////*InsertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { }) /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) +/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,] /////*PlaceOpenBraceOnNewLineForFunctions*/class foo { ////} /////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { @@ -17,6 +18,7 @@ runTest("InsertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); runTest("InsertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }"); runTest("InsertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })"); runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); +runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ]", "[1];[];[];[, ]"); runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index cbba2e916ce..42cfc1248b0 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -90,6 +90,7 @@ module FourSlashInterface { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number| string; @@ -286,10 +287,10 @@ module FourSlashInterface { } /** - Compiles the current file and evaluates 'expr' in a context containing - the emitted output, then compares (using ===) the result of that expression - to 'value'. Do not use this function with external modules as it is not supported. - */ + * Compiles the current file and evaluates 'expr' in a context containing + * the emitted output, then compares (using ===) the result of that expression + * to 'value'. Do not use this function with external modules as it is not supported. + */ public eval(expr: string, value: any) { FourSlash.currentTestState.verifyEval(expr, value); } @@ -378,6 +379,14 @@ module FourSlashInterface { FourSlash.currentTestState.verifyNoMatchingBracePosition(bracePosition); } + public DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean) { + FourSlash.currentTestState.verifyDocCommentTemplate(empty ? undefined : { newText: expectedText, caretOffset: expectedOffset }); + } + + public noDocCommentTemplate() { + this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, true); + } + public getScriptLexicalStructureListCount(count: number) { FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count); } @@ -421,6 +430,14 @@ module FourSlashInterface { FourSlash.currentTestState.verifyOccurrencesAtPositionListCount(expectedCount); } + public documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string) { + FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind); + } + + public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) { + FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch); + } + public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) { FourSlash.currentTestState.verifyCompletionEntryDetails(entryName, text, documentation, kind); } diff --git a/tests/cases/fourslash/genericsFormatting.ts b/tests/cases/fourslash/genericsFormatting.ts index 36833cadd10..f5e44522a8e 100644 --- a/tests/cases/fourslash/genericsFormatting.ts +++ b/tests/cases/fourslash/genericsFormatting.ts @@ -5,6 +5,7 @@ //// } ////} /////*typeArguments*/var foo = new Foo < number, Array < number > > ( ); +/////*typeArgumentsWithTypeLiterals*/foo = new Foo < { bar : number }, Array < { baz : string } > > ( ); //// ////interface IFoo { /////*inNewSignature*/new < T > ( a: T); @@ -13,6 +14,13 @@ //// ////foo()(); ////(a + b)(); +//// +////function bar() { +/////*inClassExpression*/ return class < T2 > { +//// } +////} +/////*expressionWithTypeArguments*/class A < T > extends bar < T >( ) < T > { +////} format.document(); @@ -25,9 +33,17 @@ verify.currentLineContentIs(" public method(a: T1, b: Array): Map goTo.marker("typeArguments"); verify.currentLineContentIs("var foo = new Foo>();"); +goTo.marker("typeArgumentsWithTypeLiterals"); +verify.currentLineContentIs("foo = new Foo<{ bar: number }, Array<{ baz: string }>>();"); goTo.marker("inNewSignature"); verify.currentLineContentIs(" new (a: T);"); goTo.marker("inOptionalMethodSignature"); -verify.currentLineContentIs(" op?(a: T, b: M);"); \ No newline at end of file +verify.currentLineContentIs(" op?(a: T, b: M);"); + +goTo.marker("inClassExpression"); +verify.currentLineContentIs(" return class {"); + +goTo.marker("expressionWithTypeArguments"); +verify.currentLineContentIs("class A extends bar() {"); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputOutFile.ts b/tests/cases/fourslash/getEmitOutputOutFile.ts new file mode 100644 index 00000000000..4a9439737ea --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputOutFile.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputOutFile.baseline +// @declaration: true +// @outFile: outFile.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts new file mode 100644 index 00000000000..19eda2ad111 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_Preserve.baseline +// @declaration: true +// @sourceMap: true +// @jsx: preserve + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_React.ts b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts new file mode 100644 index 00000000000..ccfa3bcc0c2 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_React.baseline +// @declaration: true +// @sourceMap: true +// @jsx: react + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts new file mode 100644 index 00000000000..5444ab9acdd --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts @@ -0,0 +1,56 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// public staticX; +//// constructor() { +//// this; +//// this.x; +//// this.y; +//// this.z; +//// } +//// foo() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return this.x; +//// } +//// +//// static bar() { +//// [|this|]; +//// [|this|].staticX; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts new file mode 100644 index 00000000000..ed8f8cb1d0e --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts @@ -0,0 +1,54 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// constructor() { +//// [|this|]; +//// [|this|].x; +//// [|this|].y; +//// [|this|].z; +//// } +//// foo() { +//// [|this|]; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return [|this|].x; +//// } +//// +//// static bar() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesIfElse5.ts b/tests/cases/fourslash/getOccurrencesIfElse5.ts index b0519630b7b..7360a803027 100644 --- a/tests/cases/fourslash/getOccurrencesIfElse5.ts +++ b/tests/cases/fourslash/getOccurrencesIfElse5.ts @@ -22,21 +22,21 @@ ////} ////else/*13*/ { } -function verifyOccurencesAtMarker(marker: string, count: number) { +function verifyOccurrencesAtMarker(marker: string, count: number) { goTo.marker(marker); verify.occurrencesAtPositionCount(count); } -verifyOccurencesAtMarker("1", 7); -verifyOccurencesAtMarker("2", 2); -verifyOccurencesAtMarker("3", 2); -verifyOccurencesAtMarker("4", 2); -verifyOccurencesAtMarker("5", 2); -verifyOccurencesAtMarker("6", 1); -verifyOccurencesAtMarker("7", 1); -verifyOccurencesAtMarker("8", 7); -verifyOccurencesAtMarker("9", 7); -verifyOccurencesAtMarker("10", 7); -verifyOccurencesAtMarker("11", 7); -verifyOccurencesAtMarker("12", 7); -verifyOccurencesAtMarker("13", 7); +verifyOccurrencesAtMarker("1", 7); +verifyOccurrencesAtMarker("2", 2); +verifyOccurrencesAtMarker("3", 2); +verifyOccurrencesAtMarker("4", 2); +verifyOccurrencesAtMarker("5", 2); +verifyOccurrencesAtMarker("6", 1); +verifyOccurrencesAtMarker("7", 1); +verifyOccurrencesAtMarker("8", 7); +verifyOccurrencesAtMarker("9", 7); +verifyOccurrencesAtMarker("10", 7); +verifyOccurrencesAtMarker("11", 7); +verifyOccurrencesAtMarker("12", 7); +verifyOccurrencesAtMarker("13", 7); diff --git a/tests/cases/fourslash/getOccurrencesReturn4.ts b/tests/cases/fourslash/getOccurrencesReturn4.ts index 4e25162f80f..4066b093f3d 100644 --- a/tests/cases/fourslash/getOccurrencesReturn4.ts +++ b/tests/cases/fourslash/getOccurrencesReturn4.ts @@ -19,15 +19,15 @@ //// return/*7*/ true; ////} -function verifyOccurencesAtMarker(marker: string, count: number) { +function verifyOccurrencesAtMarker(marker: string, count: number) { goTo.marker(marker); verify.occurrencesAtPositionCount(count); } -verifyOccurencesAtMarker("1", 4); -verifyOccurencesAtMarker("2", 4); -verifyOccurencesAtMarker("3", 4); -verifyOccurencesAtMarker("4", 4); -verifyOccurencesAtMarker("5", 1); -verifyOccurencesAtMarker("6", 3); -verifyOccurencesAtMarker("7", 3); \ No newline at end of file +verifyOccurrencesAtMarker("1", 4); +verifyOccurrencesAtMarker("2", 4); +verifyOccurrencesAtMarker("3", 4); +verifyOccurrencesAtMarker("4", 4); +verifyOccurrencesAtMarker("5", 1); +verifyOccurrencesAtMarker("6", 3); +verifyOccurrencesAtMarker("7", 3); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts index 162c2e1a94f..3c6d5374ce6 100644 --- a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts +++ b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts @@ -18,23 +18,23 @@ //// case 16/*14*/: ////} -function verifyOccurencesAtMarker(marker: string, count: number) { +function verifyOccurrencesAtMarker(marker: string, count: number) { goTo.marker(marker); verify.occurrencesAtPositionCount(count); } -verifyOccurencesAtMarker("1", 9); -verifyOccurencesAtMarker("2", 9); -verifyOccurencesAtMarker("3", 9); -verifyOccurencesAtMarker("4", 9); -verifyOccurencesAtMarker("5", 9); -verifyOccurencesAtMarker("6", 6); -verifyOccurencesAtMarker("7", 6); -verifyOccurencesAtMarker("8", 6); -verifyOccurencesAtMarker("9", 6); -verifyOccurencesAtMarker("10", 6); -verifyOccurencesAtMarker("11", 9); -verifyOccurencesAtMarker("12", 9); -verifyOccurencesAtMarker("13", 9); -verifyOccurencesAtMarker("14", 0); +verifyOccurrencesAtMarker("1", 9); +verifyOccurrencesAtMarker("2", 9); +verifyOccurrencesAtMarker("3", 9); +verifyOccurrencesAtMarker("4", 9); +verifyOccurrencesAtMarker("5", 9); +verifyOccurrencesAtMarker("6", 6); +verifyOccurrencesAtMarker("7", 6); +verifyOccurrencesAtMarker("8", 6); +verifyOccurrencesAtMarker("9", 6); +verifyOccurrencesAtMarker("10", 6); +verifyOccurrencesAtMarker("11", 9); +verifyOccurrencesAtMarker("12", 9); +verifyOccurrencesAtMarker("13", 9); +verifyOccurrencesAtMarker("14", 0); diff --git a/tests/cases/fourslash/getOccurrencesThis6.ts b/tests/cases/fourslash/getOccurrencesThis6.ts index 6ff779c0b46..e9a5c545f23 100644 --- a/tests/cases/fourslash/getOccurrencesThis6.ts +++ b/tests/cases/fourslash/getOccurrencesThis6.ts @@ -142,14 +142,14 @@ ////} -function verifyOccurencesAtMarker(marker: string, count: number) { +function verifyOccurrencesAtMarker(marker: string, count: number) { goTo.marker(marker); verify.occurrencesAtPositionCount(count); } -verifyOccurencesAtMarker("1", 2); -verifyOccurencesAtMarker("2", 6); -verifyOccurencesAtMarker("3", 1); -verifyOccurencesAtMarker("4", 1); -verifyOccurencesAtMarker("5", 1); -verifyOccurencesAtMarker("6", 0); \ No newline at end of file +verifyOccurrencesAtMarker("1", 2); +verifyOccurrencesAtMarker("2", 6); +verifyOccurrencesAtMarker("3", 1); +verifyOccurrencesAtMarker("4", 1); +verifyOccurrencesAtMarker("5", 1); +verifyOccurrencesAtMarker("6", 0); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts b/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts index dc6b0540312..3d97bd319ea 100644 --- a/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts +++ b/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts @@ -15,16 +15,16 @@ ////} ////finally/*7*/ { ////} -function verifyOccurencesAtMarker(marker: string, count: number) { +function verifyOccurrencesAtMarker(marker: string, count: number) { goTo.marker(marker); verify.occurrencesAtPositionCount(count); } -verifyOccurencesAtMarker("1", 3); -verifyOccurencesAtMarker("2", 2); -verifyOccurencesAtMarker("3", 2); -verifyOccurencesAtMarker("4", 2); -verifyOccurencesAtMarker("5", 2); -verifyOccurencesAtMarker("6", 3); -verifyOccurencesAtMarker("7", 3); -verifyOccurencesAtMarker("8", 0); \ No newline at end of file +verifyOccurrencesAtMarker("1", 3); +verifyOccurrencesAtMarker("2", 2); +verifyOccurrencesAtMarker("3", 2); +verifyOccurrencesAtMarker("4", 2); +verifyOccurrencesAtMarker("5", 2); +verifyOccurrencesAtMarker("6", 3); +verifyOccurrencesAtMarker("7", 3); +verifyOccurrencesAtMarker("8", 0); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts new file mode 100644 index 00000000000..aa96400a397 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts @@ -0,0 +1,11 @@ +/// + +////var x = class C { +//// /*definition*/constructor() { +//// var other = new /*usage*/C; +//// } +////} + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts new file mode 100644 index 00000000000..dc5c362772c --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts @@ -0,0 +1,16 @@ +/// + +////namespace Foo { +//// export var x; +////} +//// +////class Foo { +//// /*definition*/constructor() { +//// } +////} +//// +////var x = new /*usage*/Foo(); + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts new file mode 100644 index 00000000000..b6a10e086c2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts @@ -0,0 +1,44 @@ +/// + +////type /*0*/List = /*2*/T[] +////type /*3*/List2 = /*5*/T[]; + +type List2 = T[]; + +type L = T[] +let typeAliashDisplayParts = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: ">", kind: "punctuation" }]; + +let typeAliashDisplayParts2 = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List2", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "extends", kind: "keyword" }, + { text: " ", kind: "space" }, { text: "string", kind: "keyword" }, { text: ">", kind: "punctuation" }]; + +let typeParameterDisplayParts = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" }, { text: " ", kind: "space" }, + { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" } ] + + +goTo.marker('0'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("0").position, length: "List".length }, + typeAliashDisplayParts.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('1'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("1").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('2'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("2").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('3'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("3").position, length: "List2".length }, + typeAliashDisplayParts2.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('4'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("4").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); + +goTo.marker('5'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("5").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationClassExpression.ts b/tests/cases/fourslash/semanticClassificationClassExpression.ts new file mode 100644 index 00000000000..f067265df29 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationClassExpression.ts @@ -0,0 +1,12 @@ +/// + +//// var x = class /*0*/C {} +//// class /*1*/C {} +//// class /*2*/D extends class /*3*/B{} { } +var c = classification; +verify.semanticClassificationsAre( + c.className("C", test.marker("0").position), + c.className("C", test.marker("1").position), + c.className("D", test.marker("2").position), + c.className("B", test.marker("3").position) +); \ No newline at end of file diff --git a/tests/cases/fourslash/server/documentHighlights01.ts b/tests/cases/fourslash/server/documentHighlights01.ts new file mode 100644 index 00000000000..d4be88f9357 --- /dev/null +++ b/tests/cases/fourslash/server/documentHighlights01.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: a.ts +////function [|f|](x: typeof [|f|]) { +//// [|f|]([|f|]); +////} + +let ranges = test.ranges(); + +for (let r of ranges) { + goTo.position(r.start); + verify.documentHighlightsAtPositionCount(ranges.length, ["a.ts"]); + + for (let range of ranges) { + verify.documentHighlightsAtPositionContains(range, ["a.ts"]); + } +} + diff --git a/tests/cases/fourslash/server/documentHighlights02.ts b/tests/cases/fourslash/server/documentHighlights02.ts new file mode 100644 index 00000000000..357f82e9c2d --- /dev/null +++ b/tests/cases/fourslash/server/documentHighlights02.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: a.ts +////function [|foo|] () { +//// return 1; +////} +////[|foo|](); + +// @Filename: b.ts +/////// +////foo(); + +// open two files +goTo.file("a.ts"); +goTo.file("b.ts"); + +let ranges = test.ranges(); + +for (let i = 0; i < ranges.length; ++i) { + let r = ranges[i]; + + if (i < 2) { + goTo.file("a.ts"); + } + else { + goTo.file("b.ts"); + } + + goTo.position(r.start); + verify.documentHighlightsAtPositionCount(3, ["a.ts", "b.ts"]); + + for (let range of ranges) { + verify.documentHighlightsAtPositionContains(range, ["a.ts", "b.ts"]); + } +} diff --git a/tests/cases/fourslash/server/projectInfo.ts b/tests/cases/fourslash/server/projectInfo01.ts similarity index 100% rename from tests/cases/fourslash/server/projectInfo.ts rename to tests/cases/fourslash/server/projectInfo01.ts diff --git a/tests/cases/fourslash/server/projectInfo02.ts b/tests/cases/fourslash/server/projectInfo02.ts new file mode 100644 index 00000000000..eb86c721ac7 --- /dev/null +++ b/tests/cases/fourslash/server/projectInfo02.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: a.ts +////export var test = "test String" + +// @Filename: b.ts +////export var test2 = "test String" + +// @Filename: tsconfig.json +////{ "files": ["a.ts", "b.ts"] } + +goTo.file("a.ts") +verify.ProjectInfo(["lib.d.ts", "a.ts", "b.ts"]) diff --git a/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts b/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts new file mode 100644 index 00000000000..fc8a71197db --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts @@ -0,0 +1,43 @@ +/// + +//////curly braces +////module Foo [|{ +//// class Bar [|{ +//// private f() [|{ +//// }|] +//// +//// private f2() [|{ +//// if (true) [|{ }|] [|{ }|]; +//// }|] +//// }|] +////}|] +//// +//////parenthesis +////class FooBar { +//// private f[|()|] { +//// return [|([|(1 + 1)|])|]; +//// } +//// +//// private f2[|()|] { +//// if [|(true)|] { } +//// } +////} +//// +//////square brackets +////class Baz { +//// private f() { +//// var a: any[|[]|] = [|[[|[1, 2]|], [|[3, 4]|], 5]|]; +//// } +////} +//// +////// angular brackets +////class TemplateTest [||] { +//// public foo(a, b) { +//// return [||] a; +//// } +////} + +test.ranges().forEach((range) => { + verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); + verify.matchingBracePositionInCurrentFile(range.end - 1, range.start); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getBreakpointStatementAtPosition.ts b/tests/cases/fourslash/shims-pp/getBreakpointStatementAtPosition.ts new file mode 100644 index 00000000000..9e1d075a17f --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getBreakpointStatementAtPosition.ts @@ -0,0 +1,17 @@ +/// + +// @BaselineFile: getBreakpointStatementAtPosition.baseline +// @Filename: getBreakpointStatementAtPosition.ts +////while (true) { +//// break; +////} +////y: while (true) { +//// break y; +////} +////while (true) { +//// continue; +////} +////z: while (true) { +//// continue z; +////} +verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts b/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts new file mode 100644 index 00000000000..714d3390e76 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts @@ -0,0 +1,20 @@ +/// + +////function foo(strOrNum: string | number) { +//// /*1*/ +//// if (typeof strOrNum === "number") { +//// /*2*/ +//// } +//// else { +//// /*3*/ +//// } +////} + +goTo.marker('1'); +verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); + +goTo.marker('2'); +verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); + +goTo.marker('3'); +verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts new file mode 100644 index 00000000000..3aa31d1556c --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts @@ -0,0 +1,29 @@ +/// + +// @Filename: goToDefinitionDifferentFile_Definition.ts +////var /*remoteVariableDefinition*/remoteVariable; +/////*remoteFunctionDefinition*/function remoteFunction() { } +/////*remoteClassDefinition*/class remoteClass { } +/////*remoteInterfaceDefinition*/interface remoteInterface{ } +/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} + +// @Filename: goToDefinitionDifferentFile_Consumption.ts +/////*remoteVariableReference*/remoteVariable = 1; +/////*remoteFunctionReference*/remoteFunction(); +////var foo = new /*remoteClassReference*/remoteClass(); +////class fooCls implements /*remoteInterfaceReference*/remoteInterface { } +////var fooVar = /*remoteModuleReference*/remoteModule.foo; + +var markerList = [ + "remoteVariable", + "remoteFunction", + "remoteClass", + "remoteInterface", + "remoteModule", +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.definition(); + verify.caretAtMarker(marker + 'Definition'); +}); diff --git a/tests/cases/fourslash/shims-pp/getEmitOutput.ts b/tests/cases/fourslash/shims-pp/getEmitOutput.ts new file mode 100644 index 00000000000..45679066278 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getEmitOutput.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutput-pp.baseline +// @declaration: true + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getIndentationAtPosition.ts b/tests/cases/fourslash/shims-pp/getIndentationAtPosition.ts new file mode 100644 index 00000000000..ba2936bd702 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getIndentationAtPosition.ts @@ -0,0 +1,21 @@ +/// + +////class Bar { +//// {| "indentation": 4|} +//// private foo: string = ""; +//// {| "indentation": 4|} +//// private f() { +//// var a: any[] = [[1, 2], [3, 4], 5]; +//// {| "indentation": 8|} +//// return ((1 + 1)); +//// } +//// {| "indentation": 4|} +//// private f2() { +//// if (true) { } { }; +//// } +////} +////{| "indentation": 0|} + +test.markers().forEach((marker) => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); +}); diff --git a/tests/cases/fourslash/shims-pp/getNavigateToItems.ts b/tests/cases/fourslash/shims-pp/getNavigateToItems.ts new file mode 100644 index 00000000000..5481f4295cb --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getNavigateToItems.ts @@ -0,0 +1,27 @@ +/// + +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { +//// // Instance member +//// {| "itemName": "origin", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private origin = 0.0; +//// +//// {| "itemName": "distFromZero", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private distFromZero = 0.0; +//// +//// // Getter +//// {| "itemName": "distance", "kind": "getter", "parentName": "Point", "matchKind": "exact" |}get distance(): number { return 0; } +//// } +////} +//// +////// Local variables +////{| "itemName": "point", "kind": "var", "parentName": "", "matchKind": "exact"|}var point = new Shapes.Point(); + +//// Testing for exact matching of navigationItems + +test.markers().forEach((marker) => { + if (marker.data) { + verify.navigationItemsListContains(marker.data.itemName, marker.data.kind, marker.data.itemName, marker.data.matchKind, marker.fileName, marker.data.parentName); + } +}); diff --git a/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts new file mode 100644 index 00000000000..6c0738747f3 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts @@ -0,0 +1,13 @@ +/// + +//// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; + +test.markers().forEach(marker => { + verify.getScriptLexicalStructureListContains( + marker.data.itemName, + marker.data.kind, + marker.fileName, + marker.data.parentName, + marker.data.isAdditionalRange, + marker.position); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts b/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts new file mode 100644 index 00000000000..0654cc3962c --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts @@ -0,0 +1,18 @@ +/// + +/////*0*/ +////interface A { +//// foo: string; +////} +////function foo(x: A) { +//// x.f/*1*/oo +////} + +goTo.marker("1"); +verify.occurrencesAtPositionCount(2); + +goTo.marker("0"); +edit.insert("\r\n"); + +goTo.marker("1"); +verify.occurrencesAtPositionCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getOutliningSpans.ts b/tests/cases/fourslash/shims-pp/getOutliningSpans.ts new file mode 100644 index 00000000000..93665889eb4 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getOutliningSpans.ts @@ -0,0 +1,113 @@ +/// + +////// interface +////interface IFoo[| { +//// getDist(): number; +////}|] +//// +////// class members +////class Foo[| { +//// constructor()[| { +//// }|] +//// +//// public foo(): number[| { +//// return 0; +//// }|] +//// +//// public get X()[| { +//// return 1; +//// }|] +//// +//// public set X(v: number)[| { +//// }|] +//// +//// public member = function f()[| { +//// +//// }|] +////}|] +////switch(1)[| { +//// case 1: break; +////}|] +//// +////var array =[| [ +//// 1, +//// 2 +////]|] +//// +////// modules +////module m1[| { +//// module m2[| { }|] +//// module m3[| { +//// function foo()[| { +//// +//// }|] +//// +//// interface IFoo2[| { +//// +//// }|] +//// +//// class foo2 implements IFoo2[| { +//// +//// }|] +//// }|] +////}|] +//// +////// function declaration +////function foo(): number[| { +//// return 0; +////}|] +//// +////// function expressions +////(function f()[| { +//// +////}|]) +//// +////// trivia handeling +////class ClassFooWithTrivia[| /* some comments */ +//// /* more trivia */ { +//// +//// +//// /*some trailing trivia */ +////}|] /* even more */ +//// +////// object literals +////var x =[|{ +//// a:1, +//// b:2, +//// get foo()[| { +//// return 1; +//// }|] +////}|] +//////outline with deep nesting +////module m1[|{ +//// module m2[| { +//// module m3[| { +//// module m4[| { +//// module m5[| { +//// module m6[| { +//// module m7[| { +//// module m8[| { +//// module m9[| { +//// module m10[| { +//// module m11 { +//// module m12 { +//// export interface IFoo { +//// } +//// } +//// } +//// }|] +//// }|] +//// }|] +//// }|] +//// }|] +//// }|] +//// }|] +//// }|] +//// }|] +////}|] +//// +//////outline after a deeply nested node +////class AfterNestedNodes[| { +////}|] + +verify.outliningSpansInCurrentFile(test.ranges()); diff --git a/tests/cases/fourslash/shims-pp/getPreProcessedFile.ts b/tests/cases/fourslash/shims-pp/getPreProcessedFile.ts new file mode 100644 index 00000000000..aa0ff4c0669 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getPreProcessedFile.ts @@ -0,0 +1,30 @@ +/// + +// @Filename: refFile1.ts +//// class D { } + +// @Filename: refFile2.ts +//// export class E {} + +// @Filename: main.ts +// @ResolveReference: true +//// /// +//// /*1*/////*2*/ +//// /*3*/////*4*/ +//// import ref2 = require("refFile2"); +//// import noExistref2 = require(/*5*/"NotExistRefFile2"/*6*/); +//// import invalidRef1 /*7*/require/*8*/("refFile2"); +//// import invalidRef2 = /*9*/requi/*10*/(/*10A*/"refFile2"); +//// var obj: /*11*/C/*12*/; +//// var obj1: D; +//// var obj2: ref2.E; + +goTo.file("main.ts"); +verify.numberOfErrorsInCurrentFile(7); +verify.errorExistsBetweenMarkers("1", "2"); +verify.errorExistsBetweenMarkers("3", "4"); +verify.errorExistsBetweenMarkers("5", "6"); +verify.errorExistsBetweenMarkers("7", "8"); +verify.errorExistsBetweenMarkers("9", "10"); +verify.errorExistsBetweenMarkers("10", "10A"); +verify.errorExistsBetweenMarkers("11", "12"); diff --git a/tests/cases/fourslash/shims-pp/getQuickInfoAtPosition.ts b/tests/cases/fourslash/shims-pp/getQuickInfoAtPosition.ts new file mode 100644 index 00000000000..ef201f67096 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getQuickInfoAtPosition.ts @@ -0,0 +1,16 @@ +/// + +////class SS{} +//// +////var x/*1*/1 = new SS(); +////var x/*2*/2 = new SS(); +////var x/*3*/3 = new SS; + +goTo.marker('1'); +verify.quickInfoIs('var x1: SS'); + +goTo.marker('2'); +verify.quickInfoIs('var x2: SS<{}>'); + +goTo.marker('3'); +verify.quickInfoIs('var x3: SS<{}>'); diff --git a/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts new file mode 100644 index 00000000000..34144b74899 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts @@ -0,0 +1,29 @@ +/// + +//@Filename: findAllRefsOnDefinition-import.ts +////export class Test{ +//// +//// constructor(){ +//// +//// } +//// +//// public /*1*/start(){ +//// return this; +//// } +//// +//// public stop(){ +//// return this; +//// } +////} + +//@Filename: findAllRefsOnDefinition.ts +////import Second = require("findAllRefsOnDefinition-import"); +//// +////var second = new Second.Test() +////second.start(); +////second.stop(); + +goTo.file("findAllRefsOnDefinition-import.ts"); +goTo.marker("1"); + +verify.referencesCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getRenameInfo.ts b/tests/cases/fourslash/shims-pp/getRenameInfo.ts new file mode 100644 index 00000000000..b7a1f5d61ae --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getRenameInfo.ts @@ -0,0 +1,11 @@ +/// + +/////// + +////function /**/[|Bar|]() { +//// // This is a reference to Bar in a comment. +//// "this is a reference to Bar in a string" +////} + +goTo.marker(); +verify.renameLocations(/*findInStrings:*/ false, /*findInComments:*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getSemanticClassifications.ts b/tests/cases/fourslash/shims-pp/getSemanticClassifications.ts new file mode 100644 index 00000000000..4eb7f2a32ed --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getSemanticClassifications.ts @@ -0,0 +1,15 @@ +/// + +//// module /*0*/M { +//// export interface /*1*/I { +//// } +//// } +//// interface /*2*/X extends /*3*/M./*4*/I { } + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.interfaceName("I", test.marker("1").position), + c.interfaceName("X", test.marker("2").position), + c.moduleName("M", test.marker("3").position), + c.interfaceName("I", test.marker("4").position)); diff --git a/tests/cases/fourslash/shims-pp/getSemanticDiagnostics.ts b/tests/cases/fourslash/shims-pp/getSemanticDiagnostics.ts new file mode 100644 index 00000000000..804abbde33b --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getSemanticDiagnostics.ts @@ -0,0 +1,11 @@ +/// + +// @module: CommonJS +// @declaration: true +//// interface privateInterface {} +//// export class Bar implements /*1*/privateInterface/*2*/{ } + +verify.errorExistsBetweenMarkers("1", "2"); +verify.numberOfErrorsInCurrentFile(1); + + diff --git a/tests/cases/fourslash/shims-pp/getSignatureHelpItems.ts b/tests/cases/fourslash/shims-pp/getSignatureHelpItems.ts new file mode 100644 index 00000000000..846c2d5244a --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getSignatureHelpItems.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file0.ts +////declare function fn(x: string, y: number); + +// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file1.ts +////declare function fn(x: string); + +// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file2.ts +////fn(/*1*/ + +goTo.marker('1'); +verify.signatureHelpCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getSyntacticClassifications.ts b/tests/cases/fourslash/shims-pp/getSyntacticClassifications.ts new file mode 100644 index 00000000000..1dbe2944b8a --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getSyntacticClassifications.ts @@ -0,0 +1,35 @@ +/// + +//// // comment +//// module M { +//// var v = 0 + 1; +//// var s = "string"; +//// +//// class C { +//// } +//// +//// enum E { +//// } +//// +//// interface I { +//// } +//// +//// module M1.M2 { +//// } +//// } + +var c = classification; +verify.syntacticClassificationsAre( + c.comment("// comment"), + c.keyword("module"), c.moduleName("M"), c.punctuation("{"), + c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), + c.keyword("var"), c.identifier("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), + c.keyword("class"), c.className("C"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("enum"), c.enumName("E"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("interface"), c.interfaceName("I"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"), + c.punctuation("}"), + c.punctuation("}")); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getTodoComments.ts b/tests/cases/fourslash/shims-pp/getTodoComments.ts new file mode 100644 index 00000000000..b1e0086b93f --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getTodoComments.ts @@ -0,0 +1,3 @@ +//// // [|TODO|] + +verify.todoCommentsInCurrentFile(["TODO"]); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts new file mode 100644 index 00000000000..6b34e7e4886 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: goToTypeDefinition_Definition.ts +/////*definition*/class C { +//// p; +////} +////var c: C; + +// @Filename: goToTypeDefinition_Consumption.ts +/////*reference*/c = undefined; + +goTo.marker('reference'); +goTo.type(); +verify.caretAtMarker('definition'); diff --git a/tests/cases/fourslash/shims-pp/quickInfoDisplayPartsVar.ts b/tests/cases/fourslash/shims-pp/quickInfoDisplayPartsVar.ts new file mode 100644 index 00000000000..234c23277b6 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/quickInfoDisplayPartsVar.ts @@ -0,0 +1,86 @@ +/// + +////var /*1*/a = 10; +////function foo() { +//// var /*2*/b = /*3*/a; +////} +////module m { +//// var /*4*/c = 10; +//// export var /*5*/d = 10; +////} +////var /*6*/f: () => number; +////var /*7*/g = /*8*/f; +/////*9*/f(); +////var /*10*/h: { (a: string): number; (a: number): string; }; +////var /*11*/i = /*12*/h; +/////*13*/h(10); +/////*14*/h("hello"); + +var marker = 0; +function verifyVar(name: string, typeDisplay: ts.SymbolDisplayPart[], optionalNameDisplay?: ts.SymbolDisplayPart[], optionalKindModifiers?: string) { + marker++; + goTo.marker(marker.toString()); + var kind = "var"; + verify.verifyQuickInfoDisplayParts(kind, optionalKindModifiers || "", { start: test.markerByName(marker.toString()).position, length: name.length }, + [{ text: kind, kind: "keyword" }, + { text: " ", kind: "space" }].concat(optionalNameDisplay || [{ text: name, kind: "localName" }]).concat( + { text: ":", kind: "punctuation" }, { text: " ", kind: "space" }).concat(typeDisplay), + []); +} +function verifyLocalVar(name: string, typeDisplay: ts.SymbolDisplayPart[], optionalNameDisplay?: ts.SymbolDisplayPart[], optionalKindModifiers?: string) { + marker++; + goTo.marker(marker.toString()); + var kind = "local var"; + verify.verifyQuickInfoDisplayParts(kind, optionalKindModifiers || "", { start: test.markerByName(marker.toString()).position, length: name.length }, + [{ text: "(", kind: "punctuation" }, { text: kind, kind: "text" }, { text: ")", kind: "punctuation" }, + { text: " ", kind: "space" }].concat(optionalNameDisplay || [{ text: name, kind: "localName" }]).concat( + { text: ":", kind: "punctuation" }, { text: " ", kind: "space" }).concat(typeDisplay), + []); +} + +var numberTypeDisplay: ts.SymbolDisplayPart[] = [{ text: "number", kind: "keyword" }]; + +verifyVar("a", numberTypeDisplay); +verifyLocalVar("b", numberTypeDisplay); +verifyVar("a", numberTypeDisplay); +verifyVar("c", numberTypeDisplay); +verifyVar("d", numberTypeDisplay, [{ text: "m", kind: "moduleName" }, { text: ".", kind: "punctuation" }, { text: "d", kind: "localName" }], "export"); + +var functionTypeReturningNumber: ts.SymbolDisplayPart[] = [{ text: "(", kind: "punctuation" }, { text: ")", kind: "punctuation" }, + { text: " ", kind: "space" }, { text: "=>", kind: "punctuation" }, { text: " ", kind: "space" }, { text: "number", kind: "keyword" }]; +verifyVar("f", functionTypeReturningNumber); +verifyVar("g", functionTypeReturningNumber); +verifyVar("f", functionTypeReturningNumber); +verifyVar("f", functionTypeReturningNumber); + + +function getFunctionType(parametertype: string, returnType: string, isArrow?: boolean): ts.SymbolDisplayPart[] { + var functionTypeDisplay = [{ text: "(", kind: "punctuation" }, { text: "a", kind: "parameterName" }, { text: ":", kind: "punctuation" }, + { text: " ", kind: "space" }, { text: parametertype, kind: "keyword" }, { text: ")", kind: "punctuation" }]; + + if (isArrow) { + functionTypeDisplay = functionTypeDisplay.concat({ text: " ", kind: "space" }, { text: "=>", kind: "punctuation" }); + } + else { + functionTypeDisplay = functionTypeDisplay.concat({ text: ":", kind: "punctuation" }); + } + + return functionTypeDisplay.concat({ text: " ", kind: "space" }, { text: returnType, kind: "keyword" }); +} + +var typeLiteralWithOverloadCall: ts.SymbolDisplayPart[] = [{ text: "{", kind: "punctuation" }, { text: "\n", kind: "lineBreak" }, + { text: " ", kind: "space" }].concat(getFunctionType("string", "number")).concat( + { text: ";", kind: "punctuation" }, { text: "\n", kind: "lineBreak" }, + { text: " ", kind: "space" }).concat(getFunctionType("number", "string")).concat( + { text: ";", kind: "punctuation" }, { text: "\n", kind: "lineBreak" }, { text: "}", kind: "punctuation" }); + +verifyVar("h", typeLiteralWithOverloadCall); +verifyVar("i", typeLiteralWithOverloadCall); +verifyVar("h", typeLiteralWithOverloadCall); + +var overloadDisplay: ts.SymbolDisplayPart[] = [{ text: " ", kind: "space" }, { text: "(", kind: "punctuation" }, + { text: "+", kind: "operator" }, { text: "1", kind: "numericLiteral" }, + { text: " ", kind: "space" }, { text: "overload", kind: "text" }, { text: ")", kind: "punctuation" }]; + +verifyVar("h", getFunctionType("number", "string", /*isArrow*/true).concat(overloadDisplay)); +verifyVar("h", getFunctionType("string", "number", /*isArrow*/true).concat(overloadDisplay)); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts index 3931433e51f..2cfd27f2e3b 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -12,6 +12,6 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): voi verifyIndentationAfterNewLine("1", 4); verifyIndentationAfterNewLine("2", 4); verifyIndentationAfterNewLine("3", 4); -verifyIndentationAfterNewLine("4", 4); +verifyIndentationAfterNewLine("4", 8); verifyIndentationAfterNewLine("5", 4); verifyIndentationAfterNewLine("6", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/tsxCompletion6.ts b/tests/cases/fourslash/tsxCompletion6.ts new file mode 100644 index 00000000000..5bb01717be7 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion6.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); + +verify.completionListContains("TWO"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/tsxCompletion7.ts b/tests/cases/fourslash/tsxCompletion7.ts new file mode 100644 index 00000000000..ca489b8e0c4 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion7.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// let y = { ONE: '' }; +//// var x =
; + +goTo.marker(); + +verify.completionListContains("ONE"); +verify.completionListContains("TWO"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/tsxRename4.ts b/tests/cases/fourslash/tsxRename4.ts new file mode 100644 index 00000000000..baaa31bdc4d --- /dev/null +++ b/tests/cases/fourslash/tsxRename4.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class [|MyClass|] { +//// props: { +//// name?: string; +//// size?: number; +//// } +//// +//// +//// var x = <[|MyC/**/lass|] name='hello'>; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/tsxRename5.ts b/tests/cases/fourslash/tsxRename5.ts new file mode 100644 index 00000000000..cc18d6287c3 --- /dev/null +++ b/tests/cases/fourslash/tsxRename5.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// name?: string; +//// size?: number; +//// } +//// +//// var [|nn|]: string; +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/typeAssertionsFormatting.ts b/tests/cases/fourslash/typeAssertionsFormatting.ts new file mode 100644 index 00000000000..3f3ab070fec --- /dev/null +++ b/tests/cases/fourslash/typeAssertionsFormatting.ts @@ -0,0 +1,13 @@ +/// + +////( < any > publisher);/*1*/ +//// < any > 3;/*2*/ + + +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs("(publisher);"); + +goTo.marker("2"); +verify.currentLineContentIs("3;"); \ No newline at end of file diff --git a/tests/cases/unittests/cachingInServerLSHost.ts b/tests/cases/unittests/cachingInServerLSHost.ts new file mode 100644 index 00000000000..ff2da76ba4f --- /dev/null +++ b/tests/cases/unittests/cachingInServerLSHost.ts @@ -0,0 +1,206 @@ +/// + +module ts { + interface File { + name: string; + content: string; + } + + function createDefaultServerHost(fileMap: Map): server.ServerHost { + return { + args: [], + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: (s: string) => { + }, + readFile: (path: string, encoding?: string): string => { + return hasProperty(fileMap, path) && fileMap[path].content; + }, + writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => { + throw new Error("NYI"); + }, + resolvePath: (path: string): string => { + throw new Error("NYI"); + }, + fileExists: (path: string): boolean => { + return hasProperty(fileMap, path); + }, + directoryExists: (path: string): boolean => { + throw new Error("NYI"); + }, + createDirectory: (path: string) => { + }, + getExecutingFilePath: (): string => { + return ""; + }, + getCurrentDirectory: (): string => { + return ""; + }, + readDirectory: (path: string, extension?: string, exclude?: string[]): string[] => { + throw new Error("NYI"); + }, + exit: (exitCode?: number) => { + }, + watchFile: (path, callback) => { + return { + close: () => { } + } + } + }; + } + + function createProject(rootFile: string, serverHost: server.ServerHost): { project: server.Project, rootScriptInfo: server.ScriptInfo } { + let logger: server.Logger = { + close() { }, + isVerbose: () => false, + loggingEnabled: () => false, + perftrc: (s: string) => { }, + info: (s: string) => { }, + startGroup: () => { }, + endGroup: () => { }, + msg: (s: string, type?: string) => { } + }; + + let projectService = new server.ProjectService(serverHost, logger); + let rootScriptInfo = projectService.openFile(rootFile, /* openedByClient */true); + let project = projectService.createInferredProject(rootScriptInfo); + project.setProjectOptions( {files: [rootScriptInfo.fileName], compilerOptions: {module: ts.ModuleKind.AMD} } ); + return { + project, + rootScriptInfo + }; + } + + describe("Caching in LSHost", () => { + it("works using legacy resolution logic", () => { + let root: File = { + name: "c:/d/f0.ts", + content: `import {x} from "f1"` + }; + + let imported: File = { + name: "c:/f1.ts", + content: `foo()` + }; + + let serverHost = createDefaultServerHost({ [root.name]: root, [imported.name]: imported }); + let { project, rootScriptInfo } = createProject(root.name, serverHost); + + // ensure that imported file was found + let diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name); + assert.equal(diags.length, 1); + + let originalFileExists = serverHost.fileExists; + { + // patch fileExists to make sure that disk is not touched + serverHost.fileExists = (fileName): boolean => { + assert.isTrue(false, "fileExists should not be called"); + return false; + }; + + let newContent = `import {x} from "f1" + var x: string = 1;`; + rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + // trigger synchronization to make sure that import will be fetched from the cache + diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name); + // ensure file has correct number of errors after edit + assert.equal(diags.length, 1); + } + { + let fileExistsIsCalled = false; + serverHost.fileExists = (fileName): boolean => { + if (fileName === "lib.d.ts") { + return false; + } + fileExistsIsCalled = true; + assert.isTrue(fileName.indexOf('/f2.') !== -1); + return originalFileExists(fileName); + }; + let newContent = `import {x} from "f2"`; + rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + + try { + // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk + project.compilerService.languageService.getSemanticDiagnostics(imported.name); + assert.isTrue(false, `should not find file '${imported.name}'`) + } + catch(e) { + assert.isTrue(e.message.indexOf(`Could not find file: '${imported.name}'.`) === 0); + } + + assert.isTrue(fileExistsIsCalled); + } + { + let fileExistsCalled = false; + serverHost.fileExists = (fileName): boolean => { + if (fileName === "lib.d.ts") { + return false; + } + fileExistsCalled = true; + assert.isTrue(fileName.indexOf('/f1.') !== -1); + return originalFileExists(fileName); + }; + + let newContent = `import {x} from "f1"`; + rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); + project.compilerService.languageService.getSemanticDiagnostics(imported.name); + assert.isTrue(fileExistsCalled); + + // setting compiler options discards module resolution cache + fileExistsCalled = false; + + let opts = ts.clone(project.projectOptions); + opts.compilerOptions = ts.clone(opts.compilerOptions); + opts.compilerOptions.target = ts.ScriptTarget.ES5; + project.setProjectOptions(opts); + + project.compilerService.languageService.getSemanticDiagnostics(imported.name); + assert.isTrue(fileExistsCalled); + } + }); + + it("loads missing files from disk", () => { + let root: File = { + name: 'c:/foo.ts', + content: `import {x} from "bar"` + }; + + let imported: File = { + name: 'c:/bar.d.ts', + content: `export var y = 1` + }; + + let fileMap: Map = { [root.name]: root }; + let serverHost = createDefaultServerHost(fileMap); + let originalFileExists = serverHost.fileExists; + + let fileExistsCalledForBar = false; + serverHost.fileExists = fileName => { + if (fileName === "lib.d.ts") { + return false; + } + if (!fileExistsCalledForBar) { + fileExistsCalledForBar = fileName.indexOf("/bar.") !== -1; + } + + return originalFileExists(fileName); + }; + + let { project, rootScriptInfo } = createProject(root.name, serverHost); + + let diags = project.compilerService.languageService.getSemanticDiagnostics(root.name); + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); + assert.isTrue(diags.length === 1, "one diagnostic expected"); + assert.isTrue(typeof diags[0].messageText === "string" && ((diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message"); + + // assert that import will success once file appear on disk + fileMap[imported.name] = imported; + fileExistsCalledForBar = false; + rootScriptInfo.editContent(0, rootScriptInfo.content.length, `import {y} from "bar"`) + + diags = project.compilerService.languageService.getSemanticDiagnostics(root.name); + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); + assert.isTrue(diags.length === 0); + }) + }); +} \ No newline at end of file diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts new file mode 100644 index 00000000000..0917e72f1ce --- /dev/null +++ b/tests/cases/unittests/moduleResolution.ts @@ -0,0 +1,221 @@ +/// +/// + +declare namespace chai.assert { + function deepEqual(actual: any, expected: any): void; +} + +module ts { + + interface File { + name: string + content?: string + } + + function createModuleResolutionHost(...files: File[]): ModuleResolutionHost { + let map = arrayToMap(files, f => f.name); + + return { fileExists, readFile }; + + function fileExists(path: string): boolean { + return hasProperty(map, path); + } + + function readFile(path: string): string { + return hasProperty(map, path) ? map[path].content : undefined; + } + } + + function splitPath(path: string): { dir: string; rel: string } { + let index = path.indexOf(directorySeparator); + return index === -1 + ? { dir: path, rel: undefined } + : { dir: path.substr(0, index), rel: path.substr(index + 1) }; + } + + describe("Node module resolution - relative paths", () => { + + function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { + for (let ext of supportedExtensions) { + let containingFile = { name: containingFileName } + let moduleFile = { name: moduleFileNameNoExt + ext } + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + + let failedLookupLocations: string[] = []; + let dir = getDirectoryPath(containingFileName); + for (let e of supportedExtensions) { + if (e === ext) { + break; + } + else { + failedLookupLocations.push(normalizePath(getRootLength(moduleName) === 0 ? combinePaths(dir, moduleName) : moduleName) + e); + } + } + + assert.deepEqual(resolution.failedLookupLocations, failedLookupLocations); + } + } + + it("module name that starts with './' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/bar/foo", "./foo"); + }); + + it("module name that starts with '../' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/foo", "../foo"); + }); + + it("module name that starts with '/' script extension resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo", "/foo"); + }); + + it("module name that starts with 'c:/' script extension resolved as relative file name", () => { + testLoadAsFile("c:/foo/bar/baz.ts", "c:/foo", "c:/foo"); + }); + + function testLoadingFromPackageJson(containingFileName: string, packageJsonFileName: string, fieldRef: string, moduleFileName: string, moduleName: string): void { + let containingFile = { name: containingFileName }; + let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) }; + let moduleFile = { name: moduleFileName }; + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + // expect three failed lookup location - attempt to load module as file with all supported extensions + assert.equal(resolution.failedLookupLocations.length, 3); + } + + it("module name as directory - load from typings", () => { + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar"); + testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar"); + }); + + it ("module name as directory - load index.d.ts", () => { + let containingFile = {name: "/a/b/c.ts"}; + let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})}; + let indexFile = { name: "/a/b/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); + assert.equal(resolution.resolvedFileName, indexFile.name); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/foo.ts", + "/a/b/foo.tsx", + "/a/b/foo.d.ts", + "/a/b/foo/index.ts", + "/a/b/foo/index.tsx", + ]); + }); + }); + + describe("Node module resolution - non-relative paths", () => { + it("load module as file - ts files not loaded", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, undefined); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/c/d/node_modules/foo.d.ts", + "/a/b/c/d/node_modules/foo/package.json", + "/a/b/c/d/node_modules/foo/index.d.ts", + "/a/b/c/node_modules/foo.d.ts", + "/a/b/c/node_modules/foo/package.json", + "/a/b/c/node_modules/foo/index.d.ts", + "/a/b/node_modules/foo.d.ts", + "/a/b/node_modules/foo/package.json", + "/a/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json", + "/a/node_modules/foo/index.d.ts", + "/node_modules/foo.d.ts", + "/node_modules/foo/package.json", + "/node_modules/foo/index.d.ts" + ]) + }); + + it("load module as file", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + }); + + it("load module as directory", () => { + let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" }; + let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo.d.ts", + "/a/node_modules/b/node_modules/foo/package.json", + "/a/node_modules/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json" + ]); + }); + }); + + describe("BaseUrl mode", () => { + + it ("load module as relative url", () => { + function test(containingFileName: string, moduleFileName: string, moduleName: string): void { + let containingFile = {name: containingFileName }; + let moduleFile = { name: moduleFileName }; + let resolution = baseUrlModuleNameResolver(moduleName, containingFile.name, "", createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + let expectedFailedLookupLocations: string[] = []; + + let moduleNameHasExt = forEach(supportedExtensions, e => fileExtensionIs(moduleName, e)); + if (!moduleNameHasExt) { + let dir = getDirectoryPath(containingFileName); + + // add candidates with extensions that precede extension of the actual module name file in the list of supportd extensions + for (let ext of supportedExtensions) { + + let hasExtension = ext !== ".ts" + ? fileExtensionIs(moduleFileName, ext) + : fileExtensionIs(moduleFileName, ".ts") && !fileExtensionIs(moduleFileName, ".d.ts"); + + if (hasExtension) { + break; + } + else { + expectedFailedLookupLocations.push(normalizePath(combinePaths(dir, moduleName + ext))); + } + } + } + + assert.deepEqual(resolution.failedLookupLocations, expectedFailedLookupLocations) + } + + test("/a/b/c/d.ts", "/foo.ts", "/foo"); + test("/a/b/c/d.ts", "/foo.d.ts", "/foo"); + test("/a/b/c/d.ts", "/foo.tsx", "/foo"); + + test("/a/b/c/d.ts", "/a/b/c/foo.ts", "./foo"); + test("/a/b/c/d.ts", "/a/b/c/foo.d.ts", "./foo"); + test("/a/b/c/d.ts", "/a/b/c/foo.tsx", "./foo"); + + test("/a/b/c/d.ts", "/a/b/foo.ts", "../foo"); + test("/a/b/c/d.ts", "/a/b/foo.d.ts", "../foo"); + test("/a/b/c/d.ts", "/a/b/foo.tsx", "../foo"); + }); + + it ("load module using base url", () => { + function test(containingFileName: string, moduleFileName: string, moduleName: string, baseUrl: string): void { + let containingFile = { name: containingFileName }; + let moduleFile = { name: moduleFileName }; + let resolution = baseUrlModuleNameResolver(moduleName, containingFileName, baseUrl, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedFileName, moduleFile.name); + } + + test("/a/base/c/d.ts", "/a/base/c/d/e.ts", "c/d/e", "/a/base"); + test("/a/base/c/d.ts", "/a/base/c/d/e.d.ts", "c/d/e", "/a/base"); + test("/a/base/c/d.ts", "/a/base/c/d/e.tsx", "c/d/e", "/a/base"); + }); + }); +} \ No newline at end of file diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts new file mode 100644 index 00000000000..6c043299c8f --- /dev/null +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -0,0 +1,262 @@ +/// +/// +/// + +module ts { + + const enum ChangedPart { + references = 1 << 0, + importsAndExports = 1 << 1, + program = 1 << 2 + } + + let newLine = "\r\n"; + + interface SourceFileWithText extends SourceFile { + sourceText?: SourceText; + } + + interface NamedSourceText { + name: string; + text: SourceText + } + + interface ProgramWithSourceTexts extends Program { + sourceTexts?: NamedSourceText[]; + } + + class SourceText implements IScriptSnapshot { + private fullText: string; + + constructor(private references: string, + private importsAndExports: string, + private program: string, + private changedPart: ChangedPart = 0, + private version = 0) { + } + + static New(references: string, importsAndExports: string, program: string): SourceText { + Debug.assert(references !== undefined); + Debug.assert(importsAndExports !== undefined); + Debug.assert(program !== undefined); + return new SourceText(references + newLine, importsAndExports + newLine, program || ""); + } + + public getVersion(): number { + return this.version; + } + + public updateReferences(newReferences: string): SourceText { + Debug.assert(newReferences !== undefined); + return new SourceText(newReferences + newLine, this.importsAndExports, this.program, this.changedPart | ChangedPart.references, this.version + 1); + } + public updateImportsAndExports(newImportsAndExports: string): SourceText { + Debug.assert(newImportsAndExports !== undefined); + return new SourceText(this.references, newImportsAndExports + newLine, this.program, this.changedPart | ChangedPart.importsAndExports, this.version + 1); + } + public updateProgram(newProgram: string): SourceText { + Debug.assert(newProgram !== undefined); + return new SourceText(this.references, this.importsAndExports, newProgram, this.changedPart | ChangedPart.program, this.version + 1); + } + + public getFullText() { + return this.fullText || (this.fullText = this.references + this.importsAndExports + this.program); + } + + public getText(start: number, end: number): string { + return this.getFullText().substring(start, end); + } + + getLength(): number { + return this.getFullText().length; + } + + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { + var oldText = oldSnapshot; + var oldSpan: TextSpan; + var newLength: number; + switch (oldText.changedPart ^ this.changedPart) { + case ChangedPart.references: + oldSpan = createTextSpan(0, oldText.references.length); + newLength = this.references.length; + break; + case ChangedPart.importsAndExports: + oldSpan = createTextSpan(oldText.references.length, oldText.importsAndExports.length); + newLength = this.importsAndExports.length + break; + case ChangedPart.program: + oldSpan = createTextSpan(oldText.references.length + oldText.importsAndExports.length, oldText.program.length); + newLength = this.program.length; + break; + default: + Debug.assert(false, "Unexpected change"); + } + + return createTextChangeRange(oldSpan, newLength); + } + } + + function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost { + let files: Map = {}; + for (let t of texts) { + let file = createSourceFile(t.name, t.text.getFullText(), target); + file.sourceText = t.text; + files[t.name] = file; + } + + return { + getSourceFile(fileName): SourceFile { + return files[fileName]; + }, + getDefaultLibFileName(): string { + return "lib.d.ts" + }, + writeFile(file, text) { + throw new Error("NYI"); + }, + getCurrentDirectory(): string { + return ""; + }, + getCanonicalFileName(fileName): string { + return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + }, + useCaseSensitiveFileNames(): boolean { + return sys.useCaseSensitiveFileNames; + }, + getNewLine(): string { + return sys.newLine; + }, + fileExists: fileName => hasProperty(files, fileName), + readFile: fileName => { + let file = lookUp(files, fileName); + return file && file.text; + } + } + } + + function newProgram(texts: NamedSourceText[], rootNames: string[], options: CompilerOptions): Program { + var host = createTestCompilerHost(texts, options.target); + let program = createProgram(rootNames, options, host); + program.sourceTexts = texts; + return program; + } + + function updateProgram(oldProgram: Program, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) { + var texts: NamedSourceText[] = (oldProgram).sourceTexts.slice(0); + updater(texts); + var host = createTestCompilerHost(texts, options.target); + var program = createProgram(rootNames, options, host, oldProgram); + program.sourceTexts = texts; + return program; + } + + function getSizeOfMap(map: Map): number { + let size = 0; + for (let id in map) { + if (hasProperty(map, id)) { + size++; + } + } + return size; + } + + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { + let file = program.getSourceFile(fileName); + assert.isTrue(file !== undefined, `cannot find file ${fileName}`); + if (expectedContent === undefined) { + assert.isTrue(file.resolvedModules === undefined, "expected resolvedModules to be undefined"); + } + else { + assert.isTrue(file.resolvedModules !== undefined, "expected resolvedModuled to be set"); + let actualCacheSize = getSizeOfMap(file.resolvedModules); + let expectedSize = getSizeOfMap(expectedContent); + assert.isTrue(actualCacheSize === expectedSize, `expected actual size: ${actualCacheSize} to be equal to ${expectedSize}`); + + for (let id in expectedContent) { + if (hasProperty(expectedContent, id)) { + assert.isTrue(hasProperty(file.resolvedModules, id), `expected ${id} to be found in resolved modules`); + assert.isTrue(expectedContent[id] === file.resolvedModules[id], `expected '${expectedContent[id]}' to be equal to '${file.resolvedModules[id]}'`); + } + } + } + } + + describe("Reuse program structure", () => { + let target = ScriptTarget.Latest; + let files = [ + { name: "a.ts", text: SourceText.New(`/// `, "", `var x = 1`) }, + { name: "b.ts", text: SourceText.New(`/// `, "", `var y = 2`) }, + { name: "c.ts", text: SourceText.New("", "", `var z = 1;`) }, + ] + + it("successful if change does not affect imports", () => { + var program_1 = newProgram(files, ["a.ts"], { target }); + var program_2 = updateProgram(program_1, ["a.ts"], { target }, files => { + files[0].text = files[0].text.updateProgram("var x = 100"); + }); + assert.isTrue(program_1.structureIsReused); + }); + + it("fails if change affects tripleslash references", () => { + var program_1 = newProgram(files, ["a.ts"], { target }); + var program_2 = updateProgram(program_1, ["a.ts"], { target }, files => { + let newReferences = `/// + /// + `; + files[0].text = files[0].text.updateReferences(newReferences); + }); + assert.isTrue(!program_1.structureIsReused); + }); + + it("fails if change affects imports", () => { + var program_1 = newProgram(files, ["a.ts"], { target }); + var program_2 = updateProgram(program_1, ["a.ts"], { target }, files => { + files[2].text = files[2].text.updateImportsAndExports("import x from 'b'"); + }); + assert.isTrue(!program_1.structureIsReused); + }); + + it("fails if module kind changes", () => { + var program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS }); + var program_2 = updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, files => void 0); + assert.isTrue(!program_1.structureIsReused); + }); + + it("resolution cache follows imports", () => { + let files = [ + { name: "a.ts", text: SourceText.New("", "import {_} from 'b'", "var x = 1") }, + { name: "b.ts", text: SourceText.New("", "", "var y = 2") }, + ]; + var options: CompilerOptions = { target }; + + var program_1 = newProgram(files, ["a.ts"], options); + checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "b.ts", undefined); + + var program_2 = updateProgram(program_1, ["a.ts"], options, files => { + files[0].text = files[0].text.updateProgram("var x = 2"); + }); + assert.isTrue(program_1.structureIsReused); + + // content of resolution cache should not change + checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "b.ts", undefined); + + // imports has changed - program is not reused + var program_3 = updateProgram(program_2, ["a.ts"], options, files => { + files[0].text = files[0].text.updateImportsAndExports(""); + }); + assert.isTrue(!program_2.structureIsReused); + checkResolvedModulesCache(program_3, "a.ts", undefined); + + var program_4 = updateProgram(program_3, ["a.ts"], options, files => { + let newImports = `import x from 'b' + import y from 'c' + `; + files[0].text = files[0].text.updateImportsAndExports(newImports); + }); + assert.isTrue(!program_3.structureIsReused); + checkResolvedModulesCache(program_4, "a.ts", { "b": "b.ts", "c": undefined }); + }); + }) +} \ No newline at end of file diff --git a/tests/cases/unittests/services/colorization.ts b/tests/cases/unittests/services/colorization.ts index da1fa91036c..82f2e106aa4 100644 --- a/tests/cases/unittests/services/colorization.ts +++ b/tests/cases/unittests/services/colorization.ts @@ -9,8 +9,8 @@ interface ClassificationEntry { describe('Colorization', function () { // Use the shim adapter to ensure test coverage of the shim layer for the classifier - var languageServiceAdabtor = new Harness.LanguageService.ShimLanugageServiceAdapter(); - var classifier = languageServiceAdabtor.getClassifier(); + var languageServiceAdapter = new Harness.LanguageService.ShimLanugageServiceAdapter(/*preprocessToResolve*/ false); + var classifier = languageServiceAdapter.getClassifier(); function getEntryAtPosistion(result: ts.ClassificationResult, position: number) { var entryPosition = 0; diff --git a/tests/cases/unittests/services/documentRegistry.ts b/tests/cases/unittests/services/documentRegistry.ts index 8fc466b857f..50a144d3056 100644 --- a/tests/cases/unittests/services/documentRegistry.ts +++ b/tests/cases/unittests/services/documentRegistry.ts @@ -30,10 +30,15 @@ describe("DocumentRegistry", () => { assert(f1 !== f3, "Changed target: Expected to have different instances of document"); - compilerOptions.module = ts.ModuleKind.CommonJS; + compilerOptions.preserveConstEnums = true; var f4 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1"); - assert(f3 === f4, "Changed module: Expected to have the same instance of the document"); + assert(f3 === f4, "Changed preserveConstEnums: Expected to have the same instance of the document"); + + compilerOptions.module = ts.ModuleKind.System; + var f5 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1"); + + assert(f4 !== f5, "Changed module: Expected to have different instances of the document"); }); it("Acquiring document gets correct version 1", () => { diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index c504f444f18..982c45f0f2d 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -50,6 +50,7 @@ describe('PreProcessFile:', function () { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 37 }, { fileName: "refFile2.ts", pos: 38, end: 73 }, { fileName: "refFile3.ts", pos: 74, end: 109 }, { fileName: "..\\refFile4d.ts", pos: 110, end: 150 }], importedFiles: [], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -59,6 +60,7 @@ describe('PreProcessFile:', function () { { referencedFiles: [], importedFiles: [], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -69,6 +71,7 @@ describe('PreProcessFile:', function () { referencedFiles: [], importedFiles: [{ fileName: "r1.ts", pos: 20, end: 25 }, { fileName: "r2.ts", pos: 49, end: 54 }, { fileName: "r3.ts", pos: 78, end: 83 }, { fileName: "r4.ts", pos: 106, end: 111 }, { fileName: "r5.ts", pos: 138, end: 143 }], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -78,6 +81,7 @@ describe('PreProcessFile:', function () { { referencedFiles: [], importedFiles: [], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -87,6 +91,7 @@ describe('PreProcessFile:', function () { { referencedFiles: [], importedFiles: [{ fileName: "r3.ts", pos: 73, end: 78 }], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -96,6 +101,7 @@ describe('PreProcessFile:', function () { { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }, { fileName: "refFile2.ts", pos: 36, end: 71 }], importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }], + ambientExternalModules: undefined, isLibFile: false }); }), @@ -105,6 +111,7 @@ describe('PreProcessFile:', function () { { referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }], importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }], + ambientExternalModules: undefined, isLibFile: false }) }); @@ -129,6 +136,7 @@ describe('PreProcessFile:', function () { { fileName: "m6", pos: 160, end: 162 }, { fileName: "m7", pos: 199, end: 201 } ], + ambientExternalModules: undefined, isLibFile: false }) }); @@ -147,9 +155,24 @@ describe('PreProcessFile:', function () { { fileName: "m3", pos: 63, end: 65 }, { fileName: "m4", pos: 101, end: 103 }, ], + ambientExternalModules: undefined, isLibFile: false }) }); + + it("Correctly return ambient external modules", () => { + test(` + declare module A {} + declare module "B" {} + function foo() { + } + `, false, { + referencedFiles: [], + importedFiles: [], + ambientExternalModules: ["B"], + isLibFile: false + }) + }); }); }); diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 1fd8c860d01..0b87910d26e 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -21,22 +21,36 @@ module ts { } function test(input: string, testSettings: TranspileTestSettings): void { - let diagnostics: Diagnostic[] = []; - let transpileOptions: TranspileOptions = testSettings.options || {}; - let transpileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, diagnostics, transpileOptions.moduleName); + let transpileOptions: TranspileOptions = testSettings.options || {}; + if (!transpileOptions.compilerOptions) { + transpileOptions.compilerOptions = {}; + } + if(transpileOptions.compilerOptions.newLine === undefined) { + // use \r\n as default new line + transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + + let canUseOldTranspile = !transpileOptions.renamedDependencies; transpileOptions.reportDiagnostics = true; let transpileModuleResult = transpileModule(input, transpileOptions); - checkDiagnostics(diagnostics, testSettings.expectedDiagnosticCodes); checkDiagnostics(transpileModuleResult.diagnostics, testSettings.expectedDiagnosticCodes); if (testSettings.expectedOutput !== undefined) { - assert.equal(transpileResult, testSettings.expectedOutput); assert.equal(transpileModuleResult.outputText, testSettings.expectedOutput); } + if (canUseOldTranspile) { + let diagnostics: Diagnostic[] = []; + let transpileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, diagnostics, transpileOptions.moduleName); + checkDiagnostics(diagnostics, testSettings.expectedDiagnosticCodes); + if (testSettings.expectedOutput) { + assert.equal(transpileResult, testSettings.expectedOutput); + } + } + // check source maps if (!transpileOptions.compilerOptions) { transpileOptions.compilerOptions = {}; @@ -138,5 +152,123 @@ var x = 0;`, it("No extra errors for file without extension", () => { test(`var x = 0;`, { options: { compilerOptions: { module: ModuleKind.CommonJS }, fileName: "file" } }); }); + + it("Rename dependencies - System", () => { + let input = + `import {foo} from "SomeName";\n` + + `declare function use(a: any);\n` + + `use(foo);` + let output = + `System.register(["SomeOtherName"], function(exports_1) {\n` + + ` var SomeName_1;\n` + + ` return {\n` + + ` setters:[\n` + + ` function (SomeName_1_1) {\n` + + ` SomeName_1 = SomeName_1_1;\n` + + ` }],\n` + + ` execute: function() {\n` + + ` use(SomeName_1.foo);\n` + + ` }\n` + + ` }\n` + + `});\n` + + test(input, + { + options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + expectedOutput: output + }); + }); + + it("Rename dependencies - AMD", () => { + let input = + `import {foo} from "SomeName";\n` + + `declare function use(a: any);\n` + + `use(foo);` + let output = + `define(["require", "exports", "SomeOtherName"], function (require, exports, SomeName_1) {\n` + + ` use(SomeName_1.foo);\n` + + `});\n`; + + test(input, + { + options: { compilerOptions: { module: ModuleKind.AMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + expectedOutput: output + }); + }); + + it("Rename dependencies - UMD", () => { + let input = + `import {foo} from "SomeName";\n` + + `declare function use(a: any);\n` + + `use(foo);` + let output = + `(function (deps, factory) {\n` + + ` if (typeof module === 'object' && typeof module.exports === 'object') {\n` + + ` var v = factory(require, exports); if (v !== undefined) module.exports = v;\n` + + ` }\n` + + ` else if (typeof define === 'function' && define.amd) {\n` + + ` define(deps, factory);\n` + + ` }\n` + + `})(["require", "exports", "SomeOtherName"], function (require, exports) {\n` + + ` var SomeName_1 = require("SomeOtherName");\n` + + ` use(SomeName_1.foo);\n` + + `});\n`; + + test(input, + { + options: { compilerOptions: { module: ModuleKind.UMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + expectedOutput: output + }); + }); + + it("Transpile with emit decorators and emit metadata", () => { + let input = + `import {db} from './db';\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `} \n` + + `@someDecorator\n` + + `class MyClass {\n` + + ` db: db;\n` + + ` constructor(db: db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething(); \n` + + ` }\n` + + `}\n` + + `export {MyClass}; \n` + let output = + `var db_1 = require(\'./db\');\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `}\n` + + `var MyClass = (function () {\n` + + ` function MyClass(db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething();\n` + + ` }\n` + + ` MyClass = __decorate([\n` + + ` someDecorator, \n` + + ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` + + ` ], MyClass);\n` + + ` return MyClass;\n` + + ` var _a;\n` + + `})();\n` + + `exports.MyClass = MyClass;\n`; + + test(input, + { + options: { + compilerOptions: { + module: ModuleKind.CommonJS, + newLine: NewLineKind.LineFeed, + noEmitHelpers: true, + emitDecoratorMetadata: true, + experimentalDecorators: true, + target: ScriptTarget.ES5, + } + }, + expectedOutput: output + }); + }); }); } diff --git a/tslint.json b/tslint.json index 16a69b81f83..71dc6730de4 100644 --- a/tslint.json +++ b/tslint.json @@ -4,20 +4,31 @@ "comment-format": [true, "check-space" ], - "indent": true, + "indent": [true, + "spaces" + ], "one-line": [true, "check-open-brace" ], "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, - "quotemark": true, + "quotemark": [true, + "double" + ], "semicolon": true, "whitespace": [true, "check-branch", "check-operator", "check-separator", "check-type" - ] + ], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }] } }